class ArLazyPreload::Contexts::LazyPreloadContext
This class is responsible for lazy preloading. It contains a tree of associations, which were requested to be loaded lazily.
Attributes
association_tree[R]
Public Class Methods
new(records:, association_tree:)
click to toggle source
:records - array of ActiveRecord instances :association_tree - list of symbols or hashes representing a tree of preloadable associations
Calls superclass method
ArLazyPreload::Contexts::BaseContext::new
# 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
Protected Instance Methods
association_needs_preload?(association_name)
click to toggle source
# File lib/ar_lazy_preload/contexts/lazy_preload_context.rb, line 21 def association_needs_preload?(association_name) association_tree.any? do |node| case node when Symbol node == association_name when Hash node.key?(association_name) end end end