提交 12051770 编写于 作者: M Matthew Draper

Merge pull request #24143 from perceptec/fix-thread-mattr-accessor-refs

Fix `thread_mattr_accessor` thread-local variable naming
......@@ -47,7 +47,7 @@ def self.#{sym}
unless options[:instance_reader] == false || options[:instance_accessor] == false
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{sym}
Thread.current[:"attr_#{self.class.name}_#{sym}"]
Thread.current[:"attr_#{name}_#{sym}"]
end
EOS
end
......@@ -86,7 +86,7 @@ def self.#{sym}=(obj)
unless options[:instance_writer] == false || options[:instance_accessor] == false
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{sym}=(obj)
Thread.current[:"attr_#{self.class.name}_#{sym}"] = obj
Thread.current[:"attr_#{name}_#{sym}"] = obj
end
EOS
end
......
......@@ -106,4 +106,10 @@ def test_should_raise_name_error_if_attribute_name_is_invalid
end
assert_equal "invalid attribute name: 2valid_part", exception.message
end
def test_should_return_same_value_by_class_or_instance_accessor
@class.foo = 'fries'
assert_equal @class.foo, @object.foo
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册