aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorPeter Wagenet <peter.wagenet@gmail.com>2010-08-06 13:00:04 -0700
committerwycats <wycats@gmail.com>2010-08-16 18:36:12 -0700
commitad53b68457af0f3c4e875309f298335a17b9029c (patch)
treecbad6ec8720988bff174b73014a491ddb2bc8a19 /activesupport
parentfb6b80562041e8d2378cad1b51f8c234fe76fd5e (diff)
downloadrails-ad53b68457af0f3c4e875309f298335a17b9029c.tar.gz
rails-ad53b68457af0f3c4e875309f298335a17b9029c.tar.bz2
rails-ad53b68457af0f3c4e875309f298335a17b9029c.zip
Class Attribute setter returns set value
Signed-off-by: wycats <wycats@gmail.com>
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/class/attribute.rb1
-rw-r--r--activesupport/test/core_ext/class/attribute_test.rb5
2 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb
index 79d5c40e5f..688cba03db 100644
--- a/activesupport/lib/active_support/core_ext/class/attribute.rb
+++ b/activesupport/lib/active_support/core_ext/class/attribute.rb
@@ -72,6 +72,7 @@ class Class
remove_possible_method(:#{name})
define_method(:#{name}) { val }
end
+ val
end
def #{name}
diff --git a/activesupport/test/core_ext/class/attribute_test.rb b/activesupport/test/core_ext/class/attribute_test.rb
index 24aa5c0eba..d58b60482b 100644
--- a/activesupport/test/core_ext/class/attribute_test.rb
+++ b/activesupport/test/core_ext/class/attribute_test.rb
@@ -65,4 +65,9 @@ class ClassAttributeTest < ActiveSupport::TestCase
object.singleton_class.setting = 'foo'
assert_equal 'foo', object.setting
end
+
+ test 'setter returns set value' do
+ val = @klass.send(:setting=, 1)
+ assert_equal 1, val
+ end
end