Class: ArLazyPreload::Contexts::LazyPreloadContext

Inherits:
BaseContext
  • Object
show all
Defined in:
lib/ar_lazy_preload/contexts/lazy_preload_context.rb

Overview

This class is responsible for lazy preloading. It contains a tree of associations, which were requested to be loaded lazily.

Instance Attribute Summary collapse

Attributes inherited from BaseContext

#records

Instance Method Summary collapse

Methods inherited from BaseContext

#auto_preload?, #try_preload_lazily

Constructor Details

#initialize(records:, association_tree:) ⇒ LazyPreloadContext

:records - array of ActiveRecord instances :association_tree - list of symbols or hashes representing a tree of preloadable associations



13
14
15
16
17
# File 'lib/ar_lazy_preload/contexts/lazy_preload_context.rb', line 13

def initialize(records:, association_tree:)
  @association_tree = association_tree

  super(records: records)
end

Instance Attribute Details

#association_treeObject (readonly)

Returns the value of attribute association_tree.



8
9
10
# File 'lib/ar_lazy_preload/contexts/lazy_preload_context.rb', line 8

def association_tree
  @association_tree
end