Permalink
Browse files

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
  • Loading branch information...
1 parent 985ce47 commit 863ea1b82691b5d10ff189fef162b9f760423ed6 @rafaelfranca rafaelfranca committed Sep 12, 2013
Showing with 6 additions and 6 deletions.
  1. +1 −1 activerecord/lib/active_record/aggregations.rb
  2. +5 −5 activerecord/lib/active_record/reflection.rb
@@ -224,7 +224,7 @@ def composed_of(part_id, options = {})
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 @@ def self.create(macro, name, scope, options, ar)
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

1 comment on commit 863ea1b

💚💛❤️💙💜

Please sign in to comment.