Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

extract mutation from generation method

  • Loading branch information...
commit 5f169b2aed2476aabd9edc95577af774b469ef87 1 parent f8ea7c8
@tenderlove tenderlove authored
View
2  activerecord/lib/active_record/associations/builder/singular_association.rb
@@ -16,7 +16,7 @@ def define_accessors
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)
View
8 activerecord/lib/active_record/reflection.rb
@@ -21,14 +21,16 @@ def self.create(macro, name, scope, options, ar)
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
Please sign in to comment.
Something went wrong with that request. Please try again.