File: with_env_macro.rb

package info (click to toggle)
ruby-librarian 1.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 624 kB
  • sloc: ruby: 6,109; makefile: 11
file content (22 lines) | stat: -rw-r--r-- 318 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Support
  module WithEnvMacro

    module ClassMethods

      def with_env(new)
        old = Hash[new.map{|k, v| [k, ENV[k]]}]

        before { ENV.update(new) }
        after  { ENV.update(old) }
      end

    end

    private

    def self.included(base)
      base.extend(ClassMethods)
    end

  end
end