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
-
.cleanup ⇒ Object
Cleans up the RailLine context by resetting the depth.
-
.cleanup? ⇒ Boolean
Whether the RailLine context should be cleaned up.
-
.depth ⇒ Integer
The current depth of the RailLine context.
- .depth=(value) ⇒ Object
-
.depth_decrement ⇒ Integer
Decrements the depth of the RailLine context.
-
.depth_increment ⇒ Integer
Increments the depth of the RailLine context.
-
.nested_depth? ⇒ Boolean
Whether the RailLine context is nested.
Class Method Details
.cleanup ⇒ Object
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.
41 42 43 |
# File 'lib/rail_line/result_do/thread_context.rb', line 41 def self.cleanup? depth <= 0 end |
.depth ⇒ Integer
Returns 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
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_decrement ⇒ Integer
Decrements the 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_increment ⇒ Integer
Increments the 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.
36 37 38 |
# File 'lib/rail_line/result_do/thread_context.rb', line 36 def self.nested_depth? depth > 1 end |