module Volt::Modes::ClassMethods
Public Instance Methods
in_mode?(mode_name)
click to toggle source
Check to see if we are in the specified mode
# File lib/volt/utils/modes.rb, line 43 def in_mode?(mode_name) defined?(Thread) && Thread.current[mode_name] end
run_in_mode(mode_name) { || ... }
click to toggle source
Takes a block that when run, changes to mode inside of it
# 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
run_in_mode_if(conditional, mode_name) { || ... }
click to toggle source
# File lib/volt/utils/modes.rb, line 30 def run_in_mode_if(conditional, mode_name) if conditional # Yes, run in the mode Volt.run_in_mode(mode_name) do yield end else # Just run normally yield end end