class ArLazyPreload::Context
Public Class Methods
register(records:, association_tree:, auto_preload: false)
click to toggle source
Initiates lazy preload context for given records
# File lib/ar_lazy_preload/context.rb, line 11 def self.register(records:, association_tree:, 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