Sha256: a91b473ac76da5144f5f788737c2ae8addb70d81a2eb1c1db724215413f2c127

Contents?: true

Size: 754 Bytes

Versions: 4

Compression:

Stored size: 754 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:, 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

4 entries across 4 versions & 1 rubygems

Version Path
ar_lazy_preload-1.0.0 lib/ar_lazy_preload/context.rb
ar_lazy_preload-0.7.0 lib/ar_lazy_preload/context.rb
ar_lazy_preload-0.6.2 lib/ar_lazy_preload/context.rb
ar_lazy_preload-0.6.1 lib/ar_lazy_preload/context.rb