Module: Volt::Modes::ClassMethods
- Defined in:
- lib/volt/utils/modes.rb
Instance Method Summary collapse
-
#in_mode?(mode_name) ⇒ Boolean
Check to see if we are in the specified mode.
-
#run_in_mode(mode_name) ⇒ Object
Takes a block that when run, changes to mode inside of it.
- #run_in_mode_if(conditional, mode_name) ⇒ Object
Instance Method Details
#in_mode?(mode_name) ⇒ Boolean
Check to see if we are in the specified mode
43 44 45 |
# File 'lib/volt/utils/modes.rb', line 43 def in_mode?(mode_name) return defined?(Thread) && Thread.current[mode_name] end |
#run_in_mode(mode_name) ⇒ Object
Takes a block that when run, changes to mode inside of it
20 21 22 23 24 25 26 27 28 |
# File 'lib/volt/utils/modes.rb', line 20 def run_in_mode(mode_name) previous = Thread.current[mode_name] Thread.current[mode_name] = true begin yield ensure Thread.current[mode_name] = previous end end |