Sha256: dcd4deb4ee82436b4f575051cb8caf485e5b135149e205837c2a33a18732365a

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 Bytes

Contents

module ActiveRecord
  module Reflection
    class CountLoaderReflection < AssociationReflection
      def initialize(name, scope, options, active_record)
        super(name, scope, options, active_record)
      end

      def macro; :count_loader; end
    end
  end

  module Precount
    module ReflectionExtension
      def self.prepended(base)
        class << base
          prepend ClassMethods
        end
      end

      module ClassMethods
        def create(macro, name, scope, options, ar)
          case macro
          when :count_loader
            Reflection::CountLoaderReflection.new(name, scope, options, ar)
          else
            super(macro, name, scope, options, ar)
          end
        end
      end
    end
  end

  Reflection.prepend(Precount::ReflectionExtension)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-precount-0.6.0 lib/active_record/precount/reflection_extension.rb