Module: MongoMapper::Plugins::Associations::InstanceMethods
- Defined in:
- lib/mongo_mapper/plugins/associations.rb
Instance Method Summary collapse
- #associations ⇒ Object
- #embedded_associations ⇒ Object
- #get_proxy(association) ⇒ Object
- #save_to_collection(options = {}) ⇒ Object
Instance Method Details
#associations ⇒ Object
69 70 71 |
# File 'lib/mongo_mapper/plugins/associations.rb', line 69 def associations self.class.associations end |
#embedded_associations ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/mongo_mapper/plugins/associations.rb', line 73 def associations.select do |name, association| association. end.map do |name, association| association end end |
#get_proxy(association) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/mongo_mapper/plugins/associations.rb', line 81 def get_proxy(association) unless proxy = self.instance_variable_get(association.ivar) proxy = association.proxy_class.new(self, association) self.instance_variable_set(association.ivar, proxy) end proxy end |
#save_to_collection(options = {}) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/mongo_mapper/plugins/associations.rb', line 89 def save_to_collection(={}) super associations.each do |association_name, association| proxy = get_proxy(association) proxy.save_to_collection() if proxy.proxy_respond_to?(:save_to_collection) end end |