Class: ActiveRecord::Reflection::PolymorphicReflection

Inherits:
ThroughReflection show all
Defined in:
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.



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

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

Instance Method Details

#constraintsObject



1034
1035
1036
# File 'lib/active_record/reflection.rb', line 1034

def constraints
  @reflection.constraints + [source_type_info]
end

#join_keys(association_klass) ⇒ Object



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

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

#klassObject



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

def klass
  @reflection.klass
end

#plural_nameObject



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

def plural_name
  @reflection.plural_name
end

#scopeObject



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

def scope
  @reflection.scope
end

#source_type_infoObject



1038
1039
1040
1041
1042
# File 'lib/active_record/reflection.rb', line 1038

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



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

def table_name
  @reflection.table_name
end

#typeObject



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

def type
  @reflection.type
end