diff --git a/lib/threadsafe_attr.rb b/lib/threadsafe_attr.rb index fdd1429..462e786 100644 --- a/lib/threadsafe_attr.rb +++ b/lib/threadsafe_attr.rb @@ -9,13 +9,13 @@ def threadsafe_attr_accessor(*attrs) private def reader(attr) define_method(attr) do - Thread.current["#{self.name}.#{attr}"] + Thread.current.thread_variable_get("#{self.name}.#{attr}") end end def writer(attr) define_method("#{attr}=") do |value| - Thread.current["#{self.name}.#{attr}"] = value + Thread.current.thread_variable_set("#{self.name}.#{attr}", value) end end end