aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-11 21:24:59 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-11 21:24:59 -0300
commit863ea1b82691b5d10ff189fef162b9f760423ed6 (patch)
treedae458234f039f34f376762352dcf6c05cf821cf /activerecord/lib
parent985ce470f66f9466a2902c176422f5b5d7e4c721 (diff)
downloadrails-863ea1b82691b5d10ff189fef162b9f760423ed6.tar.gz
rails-863ea1b82691b5d10ff189fef162b9f760423ed6.tar.bz2
rails-863ea1b82691b5d10ff189fef162b9f760423ed6.zip
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
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/aggregations.rb2
-rw-r--r--activerecord/lib/active_record/reflection.rb10
2 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb
index d075edc159..0d5313956b 100644
--- a/activerecord/lib/active_record/aggregations.rb
+++ b/activerecord/lib/active_record/aggregations.rb
@@ -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
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 150a90f5db..f47282b7fd 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -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