Class: ActiveAny::Associations::Preloader::HasMany
- Inherits:
-
Association
- Object
- Association
- ActiveAny::Associations::Preloader::HasMany
- Defined in:
- lib/active_any/associations/preloader/has_many.rb
Instance Attribute Summary
Attributes inherited from Association
#inversed, #loaded, #owner, #reflection, #target
Instance Method Summary collapse
Methods inherited from Association
#association_scope, #find_from_target?, #find_target, #initialize, #klass, #load_target, #loaded!, #loaded?, #reader, #reload, #reset, #reset_scope, #scope, #set_inverse_instance, #target_scope, #writer
Constructor Details
This class inherits a constructor from ActiveAny::Associations::Association
Instance Method Details
#association_key_name ⇒ Object
15 16 17 |
# File 'lib/active_any/associations/preloader/has_many.rb', line 15 def association_key_name reflection.foreign_key end |
#owner_key_name ⇒ Object
19 20 21 |
# File 'lib/active_any/associations/preloader/has_many.rb', line 19 def owner_key_name reflection.record_class_primary_key end |
#preload(preloader) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/active_any/associations/preloader/has_many.rb', line 7 def preload(preloader) associated_records_by_owner(preloader).each do |owner, records| association = owner.association(reflection.name) association.loaded! association.target.concat(records) end end |