Sha256: 7fc6f2c06deb3b5cd38d5791ac19cdcee30d5b71406d692d09bf94c67d33b29c

Contents?: true

Size: 758 Bytes

Versions: 5

Compression:

Stored size: 758 Bytes

Contents

# frozen_string_literal: true

require "ar_lazy_preload/contexts/base_context"
require "ar_lazy_preload/contexts/auto_preload_context"
require "ar_lazy_preload/contexts/lazy_preload_context"
require "ar_lazy_preload/contexts/temporary_preload_config"

module ArLazyPreload
  class Context
    # Initiates lazy preload context for given records
    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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ar_lazy_preload-2.1.0 lib/ar_lazy_preload/context.rb
ar_lazy_preload-2.0.0 lib/ar_lazy_preload/context.rb
ar_lazy_preload-1.1.2 lib/ar_lazy_preload/context.rb
ar_lazy_preload-1.1.1 lib/ar_lazy_preload/context.rb
ar_lazy_preload-1.1.0 lib/ar_lazy_preload/context.rb