Class: ThreadAttrAccessor::ThreadStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/thread_attr_accessor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thread) ⇒ ThreadStorage

Returns a new instance of ThreadStorage.



58
59
60
# File 'lib/thread_attr_accessor.rb', line 58

def initialize(thread)
  @thread = thread
end

Instance Attribute Details

#threadObject (readonly)

Returns the value of attribute thread.



57
58
59
# File 'lib/thread_attr_accessor.rb', line 57

def thread
  @thread
end

Instance Method Details

#[](key) ⇒ Object



62
63
64
# File 'lib/thread_attr_accessor.rb', line 62

def [](key)
  thread.thread_variable_get(key)
end

#[]=(key, value) ⇒ Object



66
67
68
# File 'lib/thread_attr_accessor.rb', line 66

def []=(key, value)
  thread.thread_variable_set(key, value)
end

#has_key?(key) ⇒ Boolean

Returns:



70
71
72
# File 'lib/thread_attr_accessor.rb', line 70

def has_key?(key)
  !!thread.thread_variable_get(key)
end