Method: ActiveMongoid::Associations::RecordRelation::AutoSave::ClassMethods#autosave_record_id
- Defined in:
- lib/active_mongoid/associations/record_relation/auto_save.rb
#autosave_record_id(metadata) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/active_mongoid/associations/record_relation/auto_save.rb', line 26 def autosave_record_id() if .stores_foreign_key? save_method = :"autosave_record_id_for_#{metadata.name}" define_method(save_method) do if relation = instance_variable_get("@#{metadata.name}") self.send(.foreign_key_setter, relation.send(.primary_key)) end end before_save save_method end end |