Permalink
Browse files

Make generated_feature_methods work with ActiveRecord::Model

  • Loading branch information...
1 parent 6498695 commit 95795bcb2f3527d2b48a626e70e298a9665cfc66 @jonleighton jonleighton committed Dec 23, 2011
Showing with 13 additions and 4 deletions.
  1. +9 −4 activerecord/lib/active_record/core.rb
  2. +4 −0 activerecord/test/cases/inclusion_test.rb
@@ -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

0 comments on commit 95795bc

Please sign in to comment.