diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index 79d5c40e5fa86b880f70094793a81b70f574cc56..688cba03dba74fea10a6dc4039dbfd06d2c8ea0e 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 @@ def self.#{name}=(val) 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 24aa5c0ebad7764366e0cfe7731d1b7ef9714636..d58b60482b7021d722bf4b9957e229ee85b699af 100644 --- a/activesupport/test/core_ext/class/attribute_test.rb +++ b/activesupport/test/core_ext/class/attribute_test.rb @@ -65,4 +65,9 @@ def setup 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