Class: ActiveAny::Associations::Preloader
- Inherits:
-
Object
- Object
- ActiveAny::Associations::Preloader
- Defined in:
- lib/active_any/associations/preloader.rb,
lib/active_any/associations/preloader/has_many.rb,
lib/active_any/associations/preloader/belongs_to.rb,
lib/active_any/associations/preloader/association.rb
Defined Under Namespace
Classes: AlreadyLoaded, Association, BelongsTo, HasMany, NullPreloader
Constant Summary collapse
- NULL_RELATION =
Struct.new(:values, :where_clause, :joins_values).new({}, Relation::WhereClause.empty, [])
Instance Method Summary collapse
Instance Method Details
#preload(records, associations, scope = NULL_RELATION) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/active_any/associations/preloader.rb', line 12 def preload(records, associations, scope = NULL_RELATION) records = Array.wrap(records).compact.uniq associations = Array.wrap(associations) if records.empty? [] else associations.flat_map do |association| preloaders_on association, records, scope end end end |