File Manager

Path: /opt/chef.upgrade/embedded/lib/ruby/gems/2.3.0/gems/cheffish-5.0.1/lib/cheffish/

Viewing File: with_pattern.rb

module Cheffish
  module WithPattern
    def with(symbol)
      class_eval <<EOM
        attr_accessor :current_#{symbol}

        def with_#{symbol}(value)
          old_value = self.current_#{symbol}
          self.current_#{symbol} = value
          if block_given?
            begin
              yield
            ensure
              self.current_#{symbol} = old_value
            end
          end
        end
EOM
    end
  end
end