aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-07-23 13:06:57 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-07-23 13:06:57 -0700
commit5f169b2aed2476aabd9edc95577af774b469ef87 (patch)
tree926ac1ff06686f41b5187fa1f30bc01a5e8d913a /activerecord/lib
parentf8ea7c8b00362a5ee2981155657b6def71213a2c (diff)
downloadrails-5f169b2aed2476aabd9edc95577af774b469ef87.tar.gz
rails-5f169b2aed2476aabd9edc95577af774b469ef87.tar.bz2
rails-5f169b2aed2476aabd9edc95577af774b469ef87.zip
extract mutation from generation method
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/builder/singular_association.rb2
-rw-r--r--activerecord/lib/active_record/reflection.rb8
2 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/builder/singular_association.rb b/activerecord/lib/active_record/associations/builder/singular_association.rb
index 76e48e66e5..7bd894d6ab 100644
--- a/activerecord/lib/active_record/associations/builder/singular_association.rb
+++ b/activerecord/lib/active_record/associations/builder/singular_association.rb
@@ -16,7 +16,7 @@ module ActiveRecord::Associations::Builder
end
# Defines the (build|create)_association methods for belongs_to or has_one association
-
+
def define_constructors
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
def build_#{name}(*args, &block)
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 4bd6669f3c..de2204da29 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -21,14 +21,16 @@ module ActiveRecord
end
reflection = klass.new(macro, name, scope, options, ar)
+ add_reflection ar, name, reflection
+ reflection
+ end
- if klass == AggregateReflection
+ 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
-
- reflection
end
# \Reflection enables to interrogate Active Record classes and objects