Class: ActiveRecord::Reflection::PolymorphicReflection

Inherits:
ThroughReflection show all
Defined in:
activerecord/lib/active_record/reflection.rb

Overview

:nodoc:

Direct Known Subclasses

RuntimeReflection

Instance Attribute Summary

Attributes inherited from ThroughReflection

#delegate_reflection

Instance Method Summary collapse

Methods inherited from ThroughReflection

#add_as_polymorphic_through, #add_as_source, #add_as_through, #association_primary_key, #association_primary_key_type, #check_validity!, #clear_association_scope_cache, #collect_join_chain, #collect_join_reflections, #has_scope?, #join_id_for, #nested?, #scope_chain, #source_options, #source_reflection, #source_reflection_name, #source_reflection_names, #through_options, #through_reflection, #through_reflection?

Methods inherited from AbstractReflection

#alias_candidate, #build_association, #chain, #check_validity_of_inverse!, #class_name, #counter_cache_column, #counter_must_be_updated_by_has_many?, #has_cached_counter?, #inverse_of, #inverse_updates_counter_in_memory?, #inverse_which_updates_counter_cache, #primary_key_type, #quoted_table_name, #through_reflection?

Constructor Details

#initialize(reflection, previous_reflection) ⇒ PolymorphicReflection

Returns a new instance of PolymorphicReflection.


997
998
999
1000
# File 'activerecord/lib/active_record/reflection.rb', line 997

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

Instance Method Details

#constraintsObject


1026
1027
1028
# File 'activerecord/lib/active_record/reflection.rb', line 1026

def constraints
  @reflection.constraints + [source_type_info]
end

#join_keys(association_klass) ⇒ Object


1018
1019
1020
# File 'activerecord/lib/active_record/reflection.rb', line 1018

def join_keys(association_klass)
  @reflection.join_keys(association_klass)
end

#klassObject


1002
1003
1004
# File 'activerecord/lib/active_record/reflection.rb', line 1002

def klass
  @reflection.klass
end

#plural_nameObject


1014
1015
1016
# File 'activerecord/lib/active_record/reflection.rb', line 1014

def plural_name
  @reflection.plural_name
end

#scopeObject


1006
1007
1008
# File 'activerecord/lib/active_record/reflection.rb', line 1006

def scope
  @reflection.scope
end

#source_type_infoObject


1030
1031
1032
1033
1034
# File 'activerecord/lib/active_record/reflection.rb', line 1030

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

#table_nameObject


1010
1011
1012
# File 'activerecord/lib/active_record/reflection.rb', line 1010

def table_name
  @reflection.table_name
end

#typeObject


1022
1023
1024
# File 'activerecord/lib/active_record/reflection.rb', line 1022

def type
  @reflection.type
end