Sha256: 4981101f8c7aeaaa07113d1f4002dd494738c6b5a7a52ce84bfcc97f3de7a766

Contents?: true

Size: 538 Bytes

Versions: 6

Compression:

Stored size: 538 Bytes

Contents

# frozen_string_literal: true

module ArLazyPreload
  class Preloader
    def initialize(records, associations)
      @records = records
      @associations = associations
    end

    class << self
      def patch_for_rails_7!
        define_method(:preload) do
          ActiveRecord::Associations::Preloader.new(
            records: @records, associations: @associations
          ).call
        end
      end
    end

    def preload
      ActiveRecord::Associations::Preloader.new.preload(@records, @associations)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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