Sha256: 3ea5ae0a0cce3e05f41181afd1c18746397e98a3cb3ef63bd194b596db5d1818

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true

# Load core library
require_relative "../n1_loader"

# Load integration dependency
require "active_record"

module N1Loader
  module ActiveRecord
    class InvalidPreloading < N1Loader::Error; end
  end
end

# Library integration
ActiveSupport.on_load(:active_record) do
  require_relative "active_record/loader"
  require_relative "active_record/loader_collection"
  require_relative "active_record/base"

  case ActiveRecord::VERSION::MAJOR
  when 6
    require_relative "active_record/associations_preloader_v6"
  else
    require_relative "active_record/associations_preloader_v5"
  end

  ActiveRecord::Associations::Preloader.prepend(N1Loader::ActiveRecord::Associations::Preloader)
  ActiveRecord::Base.include(N1Loader::ActiveRecord::Base)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
n1_loader-1.4.4 lib/n1_loader/active_record.rb