From d226929e5cf16f9df38c9c95fb80d6bc33762884 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 22 May 2013 08:47:48 -0400 Subject: remove code duplication --- activerecord/lib/active_record/reflection.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 1f76adb367..27aa20b6c0 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -21,11 +21,12 @@ module ActiveRecord case macro when :has_many, :belongs_to, :has_one, :has_and_belongs_to_many klass = options[:through] ? ThroughReflection : AssociationReflection - reflection = klass.new(macro, name, scope, options, active_record) when :composed_of - reflection = AggregateReflection.new(macro, name, scope, options, active_record) + klass = AggregateReflection end + reflection = klass.new(macro, name, scope, options, active_record) + self.reflections = self.reflections.merge(name => reflection) reflection end -- cgit v1.2.3