Sha256: 3e4bc1d7161351db1e664facb0462e2ef3c003b80d5de6d107eb44293db91fcc

Contents?: true

Size: 858 Bytes

Versions: 1

Compression:

Stored size: 858 Bytes

Contents

module ActiveRecord
  module Reflection
    class AbstractReflection
      def join_scope(table, foreign_klass)
        predicate_builder = predicate_builder(table)
        scope_chain_items = join_scopes(table, predicate_builder)
        klass_scope       = klass_join_scope(table, predicate_builder)

        if type
          if options[:strict_primary_type]
            klass_scope.where!(type => BetterRecord::PolymorphicOverride.polymorphic_value(foreign_klass, options))
          else
            klass_scope.where!(type => BetterRecord::PolymorphicOverride.all_types(foreign_klass))
          end
        end

        scope_chain_items.inject(klass_scope, &:merge!)
      end
    end

    class RuntimeReflection < AbstractReflection # :nodoc:
      delegate :scope, :type, :constraints, :get_join_keys, :options, to: :@reflection
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
better_record-0.7.0 config/initializers/active_record/reflection.rb