module ThreadsafeAttributes
Public Class Methods
included(klass)
click to toggle source
# File lib/active_resource/threadsafe_attributes.rb, line 2 def self.included(klass) klass.extend(ClassMethods) end
Private Instance Methods
get_threadsafe_attribute(name)
click to toggle source
# File lib/active_resource/threadsafe_attributes.rb, line 26 def get_threadsafe_attribute(name) if threadsafe_attribute_defined_by_thread?(name, Thread.current) get_threadsafe_attribute_by_thread(name, Thread.current) elsif threadsafe_attribute_defined_by_thread?(name, Thread.main) value = get_threadsafe_attribute_by_thread(name, Thread.main) value = value.dup if value set_threadsafe_attribute_by_thread(name, value, Thread.current) value end end
get_threadsafe_attribute_by_thread(name, thread)
click to toggle source
# File lib/active_resource/threadsafe_attributes.rb, line 48 def get_threadsafe_attribute_by_thread(name, thread) thread["active.resource.#{name}.#{self.object_id}"] end
set_threadsafe_attribute(name, value)
click to toggle source
# File lib/active_resource/threadsafe_attributes.rb, line 37 def set_threadsafe_attribute(name, value) set_threadsafe_attribute_by_thread(name, value, Thread.current) unless threadsafe_attribute_defined_by_thread?(name, Thread.main) set_threadsafe_attribute_by_thread(name, value, Thread.main) end end
set_threadsafe_attribute_by_thread(name, value, thread)
click to toggle source
# File lib/active_resource/threadsafe_attributes.rb, line 52 def set_threadsafe_attribute_by_thread(name, value, thread) thread["active.resource.#{name}.#{self.object_id}.defined"] = true thread["active.resource.#{name}.#{self.object_id}"] = value end
threadsafe_attribute_defined?(name)
click to toggle source
# File lib/active_resource/threadsafe_attributes.rb, line 44 def threadsafe_attribute_defined?(name) threadsafe_attribute_defined_by_thread?(name, Thread.current) || ((Thread.current != Thread.main) && threadsafe_attribute_defined_by_thread?(name, Thread.main)) end
threadsafe_attribute_defined_by_thread?(name, thread)
click to toggle source
# File lib/active_resource/threadsafe_attributes.rb, line 57 def threadsafe_attribute_defined_by_thread?(name, thread) thread["active.resource.#{name}.#{self.object_id}.defined"] end