Sha256: 776f6e78a658666ddac7e0016d864bbcc026210b39408992e36fa544fa74d282

Contents?: true

Size: 650 Bytes

Versions: 4

Compression:

Stored size: 650 Bytes

Contents

module ActiveRecord
  # This imitates EagerLoadPolymorphicError
  class EagerLoadCountLoaderError < ActiveRecordError
    def initialize(reflection)
      super("Cannot eagerly load the count_loader association #{reflection.name.inspect}")
    end
  end

  module Precount
    module JoinDependencyExtension
      def build(associations, base_klass)
        associations.map do |name, right|
          reflection = find_reflection base_klass, name
          if reflection.macro == :count_loader
            raise EagerLoadCountLoaderError.new(reflection)
          end
        end

        super(associations, base_klass)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activerecord-precount-0.4.3 lib/active_record/precount/join_dependency_extension.rb
activerecord-precount-0.4.2 lib/active_record/precount/join_dependency_extension.rb
activerecord-precount-0.4.1 lib/active_record/precount/join_dependency_extension.rb
activerecord-precount-0.4.0 lib/active_record/precount/join_dependency_extension.rb