Class: MongoMapper::Associations::HasManyProxy
- Inherits:
-
ArrayProxy
- Object
- Proxy
- ArrayProxy
- MongoMapper::Associations::HasManyProxy
- Defined in:
- lib/mongomapper/associations/has_many_proxy.rb
Instance Attribute Summary
Attributes inherited from Proxy
Instance Method Summary collapse
Methods inherited from Proxy
#initialize, #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 16 |
# File 'lib/mongomapper/associations/has_many_proxy.rb', line 4 def replace(v) if load_target @target.map(&:destroy) end v.each do |o| @owner.save if @owner.new? o.__send__(:write_attribute, self.foreign_key, @owner.id) o.save o end reload_target end |