Module: InverseOf::AssociationPreload::ClassMethods
- Defined in:
- lib/inverse_of.rb
Instance Method Summary collapse
- #add_preloaded_records_to_collection_with_inverse_of(parent_records, reflection_name, associated_record) ⇒ Object
- #set_association_single_records_with_inverse_of(id_to_record_map, reflection_name, associated_records, key) ⇒ Object
Instance Method Details
#add_preloaded_records_to_collection_with_inverse_of(parent_records, reflection_name, associated_record) ⇒ Object
252 253 254 255 256 257 258 259 |
# File 'lib/inverse_of.rb', line 252 def add_preloaded_records_to_collection_with_inverse_of(parent_records, reflection_name, associated_record) value = add_preloaded_records_to_collection_without_inverse_of(parent_records, reflection_name, associated_record) parent_records.each do |parent_record| association_proxy = parent_record.send(reflection_name) association_proxy.__send__(:set_inverse_instance, associated_record, parent_record) end value end |
#set_association_single_records_with_inverse_of(id_to_record_map, reflection_name, associated_records, key) ⇒ Object
261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/inverse_of.rb', line 261 def set_association_single_records_with_inverse_of(id_to_record_map, reflection_name, associated_records, key) value = set_association_single_records_without_inverse_of(id_to_record_map, reflection_name, associated_records, key) associated_records.each do |associated_record| mapped_records = id_to_record_map[associated_record[key].to_s] mapped_records.each do |mapped_record| association_proxy = mapped_record.send(reflection_name) association_proxy.__send__(:set_inverse_instance, associated_record, mapped_record) end end value end |