Permalink
Browse files

Make ActiveSupport::Configurable work with modules

[#6486 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
1 parent a062992 commit f42562f97bb791a7662fce0106a93eec211b2803 Oriol Gual and Josep M. Bach committed with spastorino Feb 28, 2011
Showing with 8 additions and 2 deletions.
  1. +1 −1 activesupport/lib/active_support/configurable.rb
  2. +7 −1 activesupport/test/configurable_test.rb
@@ -26,7 +26,7 @@ def #{key}; _get(#{key.inspect}); end
module ClassMethods
def config
- @_config ||= if superclass.respond_to?(:config)
+ @_config ||= if respond_to?(:superclass) && superclass.respond_to?(:config)
superclass.config.inheritable_copy
else
# create a new "anonymous" class that will host the compiled reader methods
@@ -21,6 +21,12 @@ class Child < Parent
assert_equal({ :foo => :bar }, Parent.config)
end
+ test "adds a configuration hash to a module as well" do
+ mixin = Module.new { include ActiveSupport::Configurable }
+ mixin.config.foo = :bar
+ assert_equal({ :foo => :bar }, mixin.config)
+ end
+
test "configuration hash is inheritable" do
assert_equal :bar, Child.config.foo
assert_equal :bar, Parent.config.foo
@@ -57,4 +63,4 @@ class Child < Parent
assert_respond_to child.config, :bar
assert_respond_to child.new.config, :bar
end
-end
+end

0 comments on commit f42562f

Please sign in to comment.