mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove conditional adding a new method
At the point we want to add the reflection we already know the reflection is of the AggregateReflection type so we can call a specific method
This commit is contained in:
parent
985ce470f6
commit
863ea1b826
2 changed files with 6 additions and 6 deletions
|
@ -224,7 +224,7 @@ module ActiveRecord
|
|||
writer_method(name, class_name, mapping, allow_nil, converter)
|
||||
|
||||
reflection = ActiveRecord::Reflection.create(:composed_of, part_id, nil, options, self)
|
||||
Reflection.add_reflection self, part_id, reflection
|
||||
Reflection.add_aggregate_reflection self, part_id, reflection
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -24,11 +24,11 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def self.add_reflection(ar, name, reflection)
|
||||
if reflection.class == AggregateReflection
|
||||
ar.aggregate_reflections = ar.aggregate_reflections.merge(name => reflection)
|
||||
else
|
||||
ar.reflections = ar.reflections.merge(name => reflection)
|
||||
end
|
||||
ar.reflections = ar.reflections.merge(name => reflection)
|
||||
end
|
||||
|
||||
def self.add_aggregate_reflection(ar, name, reflection)
|
||||
ar.aggregate_reflections = ar.aggregate_reflections.merge(name => reflection)
|
||||
end
|
||||
|
||||
# \Reflection enables to interrogate Active Record classes and objects
|
||||
|
|
Loading…
Reference in a new issue