Method: Volt::Modes::ClassMethods#run_in_mode

Defined in:
lib/volt/utils/modes.rb

#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