提交 5f169b2a 编写于 作者: A Aaron Patterson

extract mutation from generation method

上级 f8ea7c8b
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册