Class: Contracts::ExecutionGuard
- Inherits:
-
Object
- Object
- Contracts::ExecutionGuard
- Defined in:
- lib/contracts.rb
Class Method Summary collapse
- .active?(key) ⇒ Boolean
- .current_stack ⇒ Object
- .depth ⇒ Object
- .enter(key) ⇒ Object
- .stack ⇒ Object
Class Method Details
.active?(key) ⇒ Boolean
158 |
# File 'lib/contracts.rb', line 158 def self.active?(key) = stack.include?(key) |
.current_stack ⇒ Object
160 |
# File 'lib/contracts.rb', line 160 def self.current_stack = stack.dup.freeze |
.depth ⇒ Object
159 |
# File 'lib/contracts.rb', line 159 def self.depth = stack.length |
.enter(key) ⇒ Object
162 163 164 165 166 167 168 169 |
# File 'lib/contracts.rb', line 162 def self.enter(key) return yield(false) if active?(key) stack << key yield(true) ensure stack.pop if stack.last == key end |
.stack ⇒ Object
153 154 155 156 |
# File 'lib/contracts.rb', line 153 def self.stack stores = Thread.current[:contracts_execution_guard] ||= {} stores[Fiber.current] ||= [] end |