Sha256: 901f5a636bffa43be66ce277705a2db66a5a67200a613e59d944942871290bef

Contents?: true

Size: 1.03 KB

Versions: 50

Compression:

Stored size: 1.03 KB

Contents

module Switchman
  module Shackles
    module ClassMethods
      def ensure_handler
        raise "This should not be called with switchman installed"
      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

    def self.included(klass)
      klass.extend(ClassMethods)
      klass.singleton_class.send(:remove_method, :ensure_handler)
      klass.singleton_class.send(:remove_method, :activate!)
      klass.singleton_class.send(:remove_method, :activate)
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
switchman-1.4.3 lib/switchman/shackles.rb
switchman-1.4.2 lib/switchman/shackles.rb
switchman-1.4.1 lib/switchman/shackles.rb
switchman-1.4.0 lib/switchman/shackles.rb
switchman-1.3.18 lib/switchman/shackles.rb
switchman-1.3.17 lib/switchman/shackles.rb
switchman-1.3.14.pre.1 lib/switchman/shackles.rb
switchman-1.3.13.pre.1 lib/switchman/shackles.rb
switchman-1.3.16 lib/switchman/shackles.rb
switchman-1.3.15 lib/switchman/shackles.rb
switchman-1.3.14 lib/switchman/shackles.rb
switchman-1.3.13 lib/switchman/shackles.rb
switchman-1.3.12 lib/switchman/shackles.rb
switchman-1.3.11 lib/switchman/shackles.rb
switchman-1.3.10 lib/switchman/shackles.rb
switchman-1.3.9 lib/switchman/shackles.rb
switchman-1.3.8 lib/switchman/shackles.rb
switchman-1.3.7 lib/switchman/shackles.rb
switchman-1.3.6 lib/switchman/shackles.rb
switchman-1.3.5 lib/switchman/shackles.rb