Sha256: 6c33e525cc7e4e4564ea4aab1ade05fcf1454fb04fd5c8014f5f89a6069dcd03

Contents?: true

Size: 975 Bytes

Versions: 6

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

require "ar_lazy_preload/active_record/base"
require "ar_lazy_preload/active_record/relation"
require "ar_lazy_preload/active_record/association"
require "ar_lazy_preload/active_record/merger"
require "ar_lazy_preload/active_record/association_relation"
require "ar_lazy_preload/active_record/collection_proxy"

module ArLazyPreload
  class Railtie < Rails::Railtie
    config.to_prepare do |_app|
      ActiveSupport.on_load(:active_record) do
        ActiveRecord::Base.include(Base)

        ActiveRecord::Relation.prepend(Relation)
        ActiveRecord::AssociationRelation.prepend(AssociationRelation)
        ActiveRecord::Relation::Merger.prepend(Merger)

        [
          ActiveRecord::Associations::CollectionAssociation,
          ActiveRecord::Associations::Association
        ].each { |klass| klass.prepend(Association) }

        ActiveRecord::Associations::CollectionProxy.prepend(CollectionProxy)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ar_lazy_preload-0.2.7 lib/ar_lazy_preload/railtie.rb
ar_lazy_preload-0.2.6 lib/ar_lazy_preload/railtie.rb
ar_lazy_preload-0.2.5 lib/ar_lazy_preload/railtie.rb
ar_lazy_preload-0.2.4 lib/ar_lazy_preload/railtie.rb
ar_lazy_preload-0.2.3 lib/ar_lazy_preload/railtie.rb
ar_lazy_preload-0.2.2 lib/ar_lazy_preload/railtie.rb