Module: ActiveRecord::Reflection::ClassMethods
- Defined in:
- lib/has_many_polymorphs/reflection.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#create_reflection(macro, name, options, active_record) ⇒ Object
Update the default reflection switch so that
:has_many_polymorphs
types get instantiated.
Instance Method Details
#create_reflection(macro, name, options, active_record) ⇒ Object
Update the default reflection switch so that :has_many_polymorphs
types get instantiated. It’s not a composed method so we have to override the whole thing.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/has_many_polymorphs/reflection.rb', line 8 def create_reflection(macro, name, , active_record) case macro when :has_many, :belongs_to, :has_one, :has_and_belongs_to_many klass = [:through] ? ThroughReflection : AssociationReflection reflection = klass.new(macro, name, , active_record) when :composed_of reflection = AggregateReflection.new(macro, name, , active_record) # added by has_many_polymorphs # when :has_many_polymorphs reflection = PolymorphicReflection.new(macro, name, , active_record) end write_inheritable_hash :reflections, name => reflection reflection end |