Module: RailLine::ResultDo::ThreadContext

Defined in:
lib/rail_line/result_do/thread_context.rb

Overview

Manages the current depth of the RailLine context for nested handle_result calls. Captured within the current thread.

Class Method Summary collapse

Class Method Details

.cleanupObject

Cleans up the RailLine context by resetting the depth



31
32
33
# File 'lib/rail_line/result_do/thread_context.rb', line 31

def self.cleanup
  Thread.current[:rail_line_depth] = nil
end

.cleanup?Boolean

Returns Whether the RailLine context should be cleaned up.

Returns:

  • (Boolean)

    Whether the RailLine context should be cleaned up



41
42
43
# File 'lib/rail_line/result_do/thread_context.rb', line 41

def self.cleanup?
  depth <= 0
end

.depthInteger

Returns The current depth of the RailLine context.

Returns:

  • (Integer)

    The current depth of the RailLine context



9
10
11
# File 'lib/rail_line/result_do/thread_context.rb', line 9

def self.depth
  Thread.current[:rail_line_depth] ||= 0
end

.depth=(value) ⇒ Object

Parameters:

  • value (Integer)

    The value to set the depth to



14
15
16
# File 'lib/rail_line/result_do/thread_context.rb', line 14

def self.depth=(value)
  Thread.current[:rail_line_depth] = value
end

.depth_decrementInteger

Decrements the depth of the RailLine context

Returns:

  • (Integer)

    The new depth of the RailLine context



26
27
28
# File 'lib/rail_line/result_do/thread_context.rb', line 26

def self.depth_decrement
  self.depth -= 1
end

.depth_incrementInteger

Increments the depth of the RailLine context

Returns:

  • (Integer)

    The new depth of the RailLine context



20
21
22
# File 'lib/rail_line/result_do/thread_context.rb', line 20

def self.depth_increment
  self.depth += 1
end

.nested_depth?Boolean

Returns Whether the RailLine context is nested.

Returns:

  • (Boolean)

    Whether the RailLine context is nested



36
37
38
# File 'lib/rail_line/result_do/thread_context.rb', line 36

def self.nested_depth?
  depth > 1
end