Class: ActiveRecord::Reflection::PolymorphicReflection

Inherits:
ThroughReflection
  • Object
show all
Defined in:
lib/has_many_polymorphs/reflection.rb

Overview

The reflection built by the has_many_polymorphs method.

Inherits from ActiveRecord::Reflection::AssociationReflection.

Instance Method Summary collapse

Instance Method Details

#check_validity!Object

Stub out the validity check. Has_many_polymorphs checks validity on macro creation, not on reflection.



38
39
40
# File 'lib/has_many_polymorphs/reflection.rb', line 38

def check_validity!
  # nothing
end

#class_nameObject

Set the classname of the target. Uses the join class name.



50
51
52
53
# File 'lib/has_many_polymorphs/reflection.rb', line 50

def class_name
  # normally is the classname of the association target
  @class_name ||= options[:join_class_name]
end

#source_reflectionObject

Return the source reflection.



43
44
45
46
47
# File 'lib/has_many_polymorphs/reflection.rb', line 43

def source_reflection
  # normally is the has_many to the through model, but we return ourselves,
  # since there isn't a real source class for a polymorphic target
  self
end