Module: Torikago::CurrentExecution
- Defined in:
- lib/torikago/current_execution.rb
Overview
Tracks which module is currently executing so Gateway can enforce caller-specific package API permissions.
Constant Summary collapse
- STORAGE_KEY =
:__torikago_current_box
Class Method Summary collapse
Class Method Details
.current_box ⇒ Object
9 10 11 |
# File 'lib/torikago/current_execution.rb', line 9 def current_box Thread.current[STORAGE_KEY] end |
.with_box(box_name) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/torikago/current_execution.rb', line 13 def with_box(box_name) previous_box = current_box Thread.current[STORAGE_KEY] = box_name.to_sym yield ensure # Gateway calls can be nested, so restore the previous caller even when a # package API raises. Thread.current[STORAGE_KEY] = previous_box end |