Sha256: 411c018c45dff587d86c90eca711a390168d3b94c32d6b202a6ce2767105cd6e

Contents?: true

Size: 793 Bytes

Versions: 24

Compression:

Stored size: 793 Bytes

Contents

module Switchman
  module Shackles
    module ClassMethods
      def self.prepended(klass)
        klass.send(:remove_method, :ensure_handler)
      end

      # drops the save_handler and ensure_handler calls from the vanilla
      # Shackles' implementation.
      def activate!(environment)
        environment ||= :master
        activated_environments << environment
        old_environment = self.environment
        @environment = environment
        old_environment
      end

      # since activate! really is just a variable swap now, it's safe to use in
      # the ensure block, simplifying the implementation
      def activate(environment)
        old_environment = activate!(environment)
        yield
      ensure
        activate!(old_environment)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
switchman-1.6.1 lib/switchman/shackles.rb
switchman-1.6.0 lib/switchman/shackles.rb
switchman-1.5.21 lib/switchman/shackles.rb
switchman-1.5.20 lib/switchman/shackles.rb
switchman-1.5.19 lib/switchman/shackles.rb
switchman-1.5.18 lib/switchman/shackles.rb
switchman-1.5.17 lib/switchman/shackles.rb
switchman-1.5.16 lib/switchman/shackles.rb
switchman-1.5.15 lib/switchman/shackles.rb
switchman-1.5.14 lib/switchman/shackles.rb
switchman-1.5.13 lib/switchman/shackles.rb
switchman-1.5.11 lib/switchman/shackles.rb
switchman-1.5.10 lib/switchman/shackles.rb
switchman-1.5.9 lib/switchman/shackles.rb
switchman-1.5.8 lib/switchman/shackles.rb
switchman-1.5.7 lib/switchman/shackles.rb
switchman-1.5.6 lib/switchman/shackles.rb
switchman-1.5.5 lib/switchman/shackles.rb
switchman-1.5.4 lib/switchman/shackles.rb
switchman-1.5.3 lib/switchman/shackles.rb