Sha256: f2b168959253aa897ae8524e3c21b8b94040e0cd8ec7618f492694c38b322a8d

Contents?: true

Size: 638 Bytes

Versions: 9

Compression:

Stored size: 638 Bytes

Contents

require_relative 'preloader/association'

unless Torque::PostgreSQL::AR521
  module Torque
    module PostgreSQL
      module Associations
        module Preloader
          BelongsToMany = Class.new(::ActiveRecord::Associations::Preloader::HasMany)

          def preloader_for(reflection, owners, *)
            return AlreadyLoaded \
              if owners.first.association(reflection.name).loaded?

            return BelongsToMany \
              if reflection.macro.eql?(:belongs_to_many)

            super
          end
        end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
torque-postgresql-1.1.6 lib/torque/postgresql/associations/preloader.rb
torque-postgresql-1.1.5 lib/torque/postgresql/associations/preloader.rb
torque-postgresql-1.1.4 lib/torque/postgresql/associations/preloader.rb
torque-postgresql-1.1.3 lib/torque/postgresql/associations/preloader.rb
torque-postgresql-1.1.2 lib/torque/postgresql/associations/preloader.rb
torque-postgresql-1.1.1 lib/torque/postgresql/associations/preloader.rb
torque-postgresql-1.1.0 lib/torque/postgresql/associations/preloader.rb
torque-postgresql-1.0.1 lib/torque/postgresql/associations/preloader.rb
torque-postgresql-1.0.0 lib/torque/postgresql/associations/preloader.rb