Class: CurrentThreadRequestId

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

Constant Summary collapse

ATTRIBUTE =
"request_id"

Class Method Summary collapse

Class Method Details

.getObject



6
7
8
# File 'lib/current_thread_request_id.rb', line 6

def self.get
  Thread.current[ATTRIBUTE]
end

.set(value) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/current_thread_request_id.rb', line 10

def self.set(value)
  throw "no block given" unless block_given?

  Thread.current[ATTRIBUTE] = value

  yield
ensure
  Thread.current[ATTRIBUTE] = nil
end