Class: Ripple::Associations::OneEmbeddedProxy

Inherits:
Proxy show all
Includes:
Embedded, One
Defined in:
ripple/lib/ripple/associations/one_embedded_proxy.rb

Instance Attribute Summary

Attributes inherited from Proxy

owner, reflection, target

Instance Method Summary (collapse)

Methods included from Embedded

#initialize

Methods included from One

#to_a

Methods included from Instantiators

#build, #create, #create!

Methods inherited from Proxy

#===, #blank?, #initialize, #inspect, #loaded, #loaded?, #nil?, #present?, #proxy_respond_to?, #reload, #reset, #respond_to?, #send

Constructor Details

This class inherits a constructor from Ripple::Associations::Embedded

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ripple::Associations::Proxy

Instance Method Details

- (Object) replace(doc)



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'ripple/lib/ripple/associations/one_embedded_proxy.rb', line 25

def replace(doc)
  @reflection.verify_type!(doc, @owner)
  @_doc = doc.respond_to?(:attributes_for_persistence) ? doc.attributes_for_persistence : doc
  assign_references(doc)

  if doc.is_a?(@reflection.klass)
    loaded
    @target = doc
  else
    reset
  end

  @_doc
end