Class: Ripple::Associations::ManyEmbeddedProxy

Inherits:
Proxy show all
Includes:
Embedded, Many
Defined in:
lib/ripple/associations/many_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 Many

#count, #reset, #to_ary

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

#<<(docs) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/ripple/associations/many_embedded_proxy.rb', line 11

def <<(docs)
  load_target
  docs = Array.wrap(docs)
  @reflection.verify_type!(docs, @owner)
  assign_references(docs)
  @target += docs
  self
end

#replace(docs) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/ripple/associations/many_embedded_proxy.rb', line 20

def replace(docs)
  @reflection.verify_type!(docs, @owner)
  @_docs = docs.map { |doc| attrs = doc.respond_to?(:attributes_for_persistence) ? doc.attributes_for_persistence : doc }
  assign_references(docs)
  reset
  @_docs
end