Sha256: 18dbffcba34a7a754d01cef0ad0460e045053cbca5bded941572f91c4f846a3d

Contents?: true

Size: 533 Bytes

Versions: 9

Compression:

Stored size: 533 Bytes

Contents

# frozen_string_literal: true

module ArLazyPreload
  # ActiveRecord::Base patch with lazy preloading support
  module Base
    def self.included(base)
      base.class.delegate :lazy_preload, to: :all
      base.class.delegate :preload_associations_lazily, to: :all
    end

    attr_accessor :lazy_preload_context

    delegate :try_preload_lazily, to: :lazy_preload_context, allow_nil: true

    def skip_preload
      lazy_preload_context&.records&.delete(self)
      self.lazy_preload_context = nil
      self
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ar_lazy_preload-1.0.0 lib/ar_lazy_preload/active_record/base.rb
ar_lazy_preload-0.7.0 lib/ar_lazy_preload/active_record/base.rb
ar_lazy_preload-0.6.2 lib/ar_lazy_preload/active_record/base.rb
ar_lazy_preload-0.6.1 lib/ar_lazy_preload/active_record/base.rb
ar_lazy_preload-0.6.0 lib/ar_lazy_preload/active_record/base.rb
ar_lazy_preload-0.5.2 lib/ar_lazy_preload/active_record/base.rb
ar_lazy_preload-0.5.1 lib/ar_lazy_preload/active_record/base.rb
ar_lazy_preload-0.5.0 lib/ar_lazy_preload/active_record/base.rb
ar_lazy_preload-0.4.0 lib/ar_lazy_preload/active_record/base.rb