Class: PireLoader::Loaders::Singular
- Inherits:
-
Object
- Object
- PireLoader::Loaders::Singular
- Defined in:
- lib/pire_loader/loaders/singular.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(association) ⇒ Singular
constructor
A new instance of Singular.
- #preload ⇒ Object
Constructor Details
#initialize(association) ⇒ Singular
Returns a new instance of Singular.
12 13 14 |
# File 'lib/pire_loader/loaders/singular.rb', line 12 def initialize(association) @association = association end |
Class Method Details
.preload(association) ⇒ Object
8 9 10 |
# File 'lib/pire_loader/loaders/singular.rb', line 8 def self.preload(association) new(association).preload end |
Instance Method Details
#preload ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pire_loader/loaders/singular.rb', line 16 def preload owner_records.each do |record| join_value = record[join_foreign_key] record.association(reflection.name).target = associated_records[join_value] end end |