Class: MongoMapper::Associations::ManyEmbeddedPolymorphicProxy

Inherits:
Proxy
  • Object
show all
Defined in:
lib/mongomapper/associations/many_embedded_polymorphic_proxy.rb

Instance Attribute Summary

Attributes inherited from Proxy

#association, #owner

Instance Method Summary collapse

Methods inherited from Proxy

#initialize, #inspect, #nil?, #reload_target, #reset, #respond_to?, #send

Constructor Details

This class inherits a constructor from MongoMapper::Associations::Proxy

Dynamic Method Handling

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

Instance Method Details

#replace(v) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/mongomapper/associations/many_embedded_polymorphic_proxy.rb', line 4

def replace(v)
  @_values = v.map do |doc_or_hash|
    if doc_or_hash.kind_of?(EmbeddedDocument)
      doc = doc_or_hash
      {@association.type_key_name => doc.class.name}.merge(doc.attributes)
    else
      doc_or_hash
    end
  end
  
  reset
end