Module: Switchman::GuardRail::ClassMethods

Defined in:
lib/switchman/guard_rail.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(klass) ⇒ Object



6
7
8
# File 'lib/switchman/guard_rail.rb', line 6

def self.prepended(klass)
  klass.send(:remove_method, :ensure_handler)
end

Instance Method Details

#activate(environment) ⇒ Object

since activate! really is just a variable swap now, it’s safe to use in the ensure block, simplifying the implementation



22
23
24
25
26
27
# File 'lib/switchman/guard_rail.rb', line 22

def activate(environment)
  old_environment = activate!(environment)
  yield
ensure
  activate!(old_environment)
end

#activate!(environment) ⇒ Object

drops the save_handler and ensure_handler calls from the vanilla GuardRail’ implementation.



12
13
14
15
16
17
18
# File 'lib/switchman/guard_rail.rb', line 12

def activate!(environment)
  environment ||= :primary
  activated_environments << environment
  old_environment = self.environment
  Thread.current[:guard_rail_environment] = environment
  old_environment
end