提交 95795bcb 编写于 作者: J Jon Leighton

Make generated_feature_methods work with ActiveRecord::Model

上级 64986955
......@@ -62,21 +62,26 @@ module Core
Configuration.define :timestamped_migrations, true
included do
##
# :singleton-method:
# The connection handler
class_attribute :connection_handler, :instance_writer => false
initialize_generated_modules
end
module ClassMethods
def inherited(child_class) #:nodoc:
# force attribute methods to be higher in inheritance hierarchy than other generated methods
child_class.generated_attribute_methods
child_class.generated_feature_methods
child_class.initialize_generated_modules
super
end
def initialize_generated_modules
# force attribute methods to be higher in inheritance hierarchy than other generated methods
generated_attribute_methods
generated_feature_methods
end
def generated_feature_methods
@generated_feature_methods ||= begin
mod = const_set(:GeneratedFeatureMethods, Module.new)
......
......@@ -14,6 +14,10 @@ def test_inherited_model
assert_equal "Bob", teapot.name
assert_equal "mmm", teapot.aaahhh
end
def test_generated_feature_methods
assert Teapot < Teapot::GeneratedFeatureMethods
end
end
class InclusionUnitTest < ActiveRecord::TestCase
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册