Class: Ripple::Associations::OneEmbeddedProxy

Inherits:
Proxy show all
Includes:
Embedded, One
Defined in:
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?, #has_changed_documents?, #initialize, #inspect, #loaded, #loaded?, #loaded_documents, #nil?, #present?, #proxy_respond_to?, #reload, #reset, #respond_to?, #send

Dynamic Method Handling

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

Instance Method Details

#replace(doc) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ripple/associations/one_embedded_proxy.rb', line 11

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