提交 8e814a0a 编写于 作者: K kennyj

Renamed generated_feature_methods to generated_association_methods.

上级 3e0a60e4
......@@ -83,7 +83,7 @@ def define_callbacks(model, reflection)
# Post.first.comments and Post.first.comments= methods are defined by this method...
def define_accessors(model)
mixin = model.generated_feature_methods
mixin = model.generated_association_methods
define_readers(mixin)
define_writers(mixin)
end
......
......@@ -12,7 +12,7 @@ def constructable?
def define_accessors(model)
super
define_constructors(model.generated_feature_methods) if constructable?
define_constructors(model.generated_association_methods) if constructable?
end
# Defines the (build|create)_association methods for belongs_to or has_one association
......
......@@ -91,12 +91,12 @@ module ClassMethods
def initialize_generated_modules
super
generated_feature_methods
generated_association_methods
end
def generated_feature_methods
@generated_feature_methods ||= begin
mod = const_set(:GeneratedFeatureMethods, Module.new)
def generated_association_methods
@generated_association_methods ||= begin
mod = const_set(:GeneratedAssociationMethods, Module.new)
include mod
mod
end
......
......@@ -335,7 +335,7 @@ def accepts_nested_attributes_for(*attr_names)
# the helper methods defined below. Makes it seem like the nested
# associations are just regular associations.
def generate_association_writer(association_name, type)
generated_feature_methods.module_eval <<-eoruby, __FILE__, __LINE__ + 1
generated_association_methods.module_eval <<-eoruby, __FILE__, __LINE__ + 1
if method_defined?(:#{association_name}_attributes=)
remove_method(:#{association_name}_attributes=)
end
......
......@@ -86,11 +86,11 @@ def setup
def test_generated_methods_modules
modules = Computer.ancestors
assert modules.include?(Computer::GeneratedFeatureMethods)
assert_equal(Computer::GeneratedFeatureMethods, Computer.generated_feature_methods)
assert(modules.index(Computer.generated_attribute_methods) > modules.index(Computer.generated_feature_methods),
"generated_attribute_methods must be higher in inheritance hierarchy than generated_feature_methods")
assert_not_equal Computer.generated_feature_methods, Post.generated_feature_methods
assert modules.include?(Computer::GeneratedAssociationMethods)
assert_equal(Computer::GeneratedAssociationMethods, Computer.generated_association_methods)
assert(modules.index(Computer.generated_attribute_methods) > modules.index(Computer.generated_association_methods),
"generated_attribute_methods must be higher in inheritance hierarchy than generated_association_methods")
assert_not_equal Computer.generated_association_methods, Post.generated_association_methods
assert(modules.index(Computer.generated_attribute_methods) < modules.index(ActiveRecord::Base.ancestors[1]))
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册