Sha256: 47cce8fea38b0830d24c77428d9fbe3e56155ecec6903af3c01da19230c10378

Contents?: true

Size: 653 Bytes

Versions: 7

Compression:

Stored size: 653 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 CountLoader
    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

7 entries across 7 versions & 1 rubygems

Version Path
activerecord-count_loader-0.3.3 lib/active_record/count_loader/join_dependency_extension.rb
activerecord-count_loader-0.3.2 lib/active_record/count_loader/join_dependency_extension.rb
activerecord-count_loader-0.3.1 lib/active_record/count_loader/join_dependency_extension.rb
activerecord-count_loader-0.3.0 lib/active_record/count_loader/join_dependency_extension.rb
activerecord-count_loader-0.2.2 lib/active_record/count_loader/join_dependency_extension.rb
activerecord-count_loader-0.2.1 lib/active_record/count_loader/join_dependency_extension.rb
activerecord-count_loader-0.2.0 lib/active_record/count_loader/join_dependency_extension.rb