aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-12-17 16:15:29 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-12-17 16:15:41 +0100
commit301f43820562c6a70dffe30f4227ff0751f47d4f (patch)
tree6f08f6d2f2bc00361f2e03ea1c405f0be6f52d0c /activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb
parentce28270e6fa4d65e470c36160299030303207166 (diff)
downloadrails-301f43820562c6a70dffe30f4227ff0751f47d4f.tar.gz
rails-301f43820562c6a70dffe30f4227ff0751f47d4f.tar.bz2
rails-301f43820562c6a70dffe30f4227ff0751f47d4f.zip
Use Thread.current.thread_variable_set/get insetad of the direct accessors
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb b/activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb
index 34ba014856..eb65a60112 100644
--- a/activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb
+++ b/activesupport/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb
@@ -40,14 +40,14 @@ class Module
raise NameError.new("invalid attribute name: #{sym}") unless sym =~ /^[_A-Za-z]\w*$/
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def self.#{sym}
- Thread.current[:"attr_#{name}_#{sym}"]
+ Thread.current.thread_variable_get "attr_#{name}_#{sym}"
end
EOS
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.thread_variable_get "attr_#{self.class.name}_#{sym}"
end
EOS
end
@@ -79,14 +79,14 @@ class Module
raise NameError.new("invalid attribute name: #{sym}") unless sym =~ /^[_A-Za-z]\w*$/
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def self.#{sym}=(obj)
- Thread.current[:"attr_#{name}_#{sym}"] = obj
+ Thread.current.thread_variable_set "attr_#{name}_#{sym}", obj
end
EOS
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.thread_variable_set "attr_#{self.class.name}_#{sym}", obj
end
EOS
end