Module: Oboe::ThreadLocal

Included in:
OboeBase
Defined in:
lib/oboe/thread_local.rb

Overview

Provides thread local storage for Oboe.

Example usage: module OboeBase

extend ::Oboe::ThreadLocal
thread_local :layer_op

end

Instance Method Summary collapse

Instance Method Details

#thread_local(name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/oboe/thread_local.rb', line 14

def thread_local(name)
  key = "__#{self}_#{name}__".intern

  define_method(name) do
    Thread.current[key]
  end

  define_method(name.to_s + '=') do |value|
    Thread.current[key] = value
  end
end