123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::Reflection::PolymorphicReflection

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveRecord::Reflection::AbstractReflection
Defined in: activerecord/lib/active_record/reflection.rb

Class Method Summary

Instance Attribute Summary

AbstractReflection - Inherited

#counter_must_be_updated_by_has_many?,
#has_active_cached_counter?

Returns whether this association has a counter cache and its column values were backfilled (and so it is used internally by methods like size/any?/etc).

#has_cached_counter?

Returns whether this association has a counter cache.

#inverse_updates_counter_cache?
#inverse_updates_counter_in_memory?, #strict_loading?, #through_reflection?

Instance Method Summary

Constructor Details

.new(reflection, previous_reflection) ⇒ PolymorphicReflection

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1232

def initialize(reflection, previous_reflection)
  super()
  @reflection = reflection
  @previous_reflection = previous_reflection
end

Instance Attribute Details

#join_foreign_key (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1229

delegate :klass, :scope, :plural_name, :type, :join_primary_key, :join_foreign_key,
         :name, :scope_for, to: :@reflection

#join_primary_key (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1229

delegate :klass, :scope, :plural_name, :type, :join_primary_key, :join_foreign_key,
         :name, :scope_for, to: :@reflection

#klass (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1229

delegate :klass, :scope, :plural_name, :type, :join_primary_key, :join_foreign_key,
         :name, :scope_for, to: :@reflection

#name (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1229

delegate :klass, :scope, :plural_name, :type, :join_primary_key, :join_foreign_key,
         :name, :scope_for, to: :@reflection

#plural_name (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1229

delegate :klass, :scope, :plural_name, :type, :join_primary_key, :join_foreign_key,
         :name, :scope_for, to: :@reflection

#scope (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1229

delegate :klass, :scope, :plural_name, :type, :join_primary_key, :join_foreign_key,
         :name, :scope_for, to: :@reflection

#scope_for (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1229

delegate :klass, :scope, :plural_name, :type, :join_primary_key, :join_foreign_key,
         :name, :scope_for, to: :@reflection

#type (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1229

delegate :klass, :scope, :plural_name, :type, :join_primary_key, :join_foreign_key,
         :name, :scope_for, to: :@reflection

Instance Method Details

#constraints

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1246

def constraints
  @reflection.constraints + [source_type_scope]
end

#join_scopes(table, predicate_builder = nil, klass = self.klass, record = nil)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1238

def join_scopes(table, predicate_builder = nil, klass = self.klass, record = nil) # :nodoc:
  scopes = super
  unless @previous_reflection.through_reflection?
    scopes += @previous_reflection.join_scopes(table, predicate_builder, klass, record)
  end
  scopes << build_scope(table, predicate_builder, klass).instance_exec(record, &source_type_scope)
end

#source_type_scope (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1251

def source_type_scope
  type = @previous_reflection.foreign_type
  source_type = @previous_reflection.options[:source_type]
  lambda { |object| where(type => source_type) }
end