Module: Switchman::Shackles::ClassMethods

Defined in:
lib/switchman/shackles.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(klass) ⇒ Object



4
5
6
# File 'lib/switchman/shackles.rb', line 4

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



20
21
22
23
24
25
# File 'lib/switchman/shackles.rb', line 20

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 Shackles’ implementation.



10
11
12
13
14
15
16
# File 'lib/switchman/shackles.rb', line 10

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