Class: ActiveRecord::Reflection::PolymorphicReflection

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

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from AbstractReflection

#alias_candidate, #build_association, #build_scope, #chain, #check_validity_of_inverse!, #class_name, #counter_cache_column, #counter_must_be_updated_by_has_many?, #has_active_cached_counter?, #has_cached_counter?, #inverse_of, #inverse_updates_counter_in_memory?, #inverse_which_updates_counter_cache, #join_scope, #klass_join_scope, #scopes, #strict_loading?, #strict_loading_violation_message, #table_name, #through_reflection?

Constructor Details

#initialize(reflection, previous_reflection) ⇒ PolymorphicReflection

Returns a new instance of PolymorphicReflection.



1235
1236
1237
1238
1239
# File 'lib/active_record/reflection.rb', line 1235

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

Instance Method Details

#constraintsObject



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

def constraints
  @reflection.constraints + [source_type_scope]
end

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

:nodoc:



1241
1242
1243
1244
1245
1246
1247
# File 'lib/active_record/reflection.rb', line 1241

def join_scopes(table, predicate_builder, 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