Class: MongoMapper::Associations::BelongsToPolymorphicProxy
- Defined in:
- lib/mongo_mapper/associations/belongs_to_polymorphic_proxy.rb
Instance Attribute Summary
Attributes inherited from Proxy
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(doc) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/mongo_mapper/associations/belongs_to_polymorphic_proxy.rb', line 4 def replace(doc) if doc doc.save if doc.new? id, type = doc.id, doc.class.name end @owner.send("#{@association.foreign_key}=", id) @owner.send("#{@association.type_key_name}=", type) reset end |