Class: MongoMapper::Plugins::Associations::OneEmbeddedProxy
- Defined in:
- lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb
Instance Attribute Summary
Attributes inherited from Proxy
Instance Method Summary collapse
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 MongoMapper::Plugins::Associations::Proxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class MongoMapper::Plugins::Associations::Proxy
Instance Method Details
#build(attributes = {}) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb', line 8 def build(attributes={}) @target = klass.new(attributes) assign_references(@target) loaded @target end |
#replace(doc) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb', line 15 def replace(doc) if doc.respond_to?(:attributes) @target = klass.load(doc.attributes) else @target = klass.load(doc) end assign_references(@target) loaded @target end |