Class: ArLazyPreload::Context
- Inherits:
-
Object
- Object
- ArLazyPreload::Context
- Defined in:
- lib/ar_lazy_preload/context.rb
Class Method Summary collapse
-
.register(records:, association_tree: nil, auto_preload: false) ⇒ Object
Initiates lazy preload context for given records.
Class Method Details
.register(records:, association_tree: nil, auto_preload: false) ⇒ Object
Initiates lazy preload context for given records
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ar_lazy_preload/context.rb', line 11 def self.register(records:, association_tree: nil, auto_preload: false) return if records.empty? if ArLazyPreload.config.auto_preload? || auto_preload Contexts::AutoPreloadContext.new(records: records) elsif association_tree.any? Contexts::LazyPreloadContext.new( records: records, association_tree: association_tree ) end end |