Module: IceAge

Extended by:
IceAge
Included in:
IceAge
Defined in:
lib/ice_age.rb,
lib/ice_age/version.rb

Constant Summary collapse

VERSION =
'0.2.0'

Instance Method Summary collapse

Instance Method Details

#endure!Object



23
24
25
26
27
28
29
30
31
# File 'lib/ice_age.rb', line 23

def endure!
  raise 'not frozen' unless frozen?

  changes = (Set.new(ENV.to_h) - Set.new(@env)).to_h.keys - WHITELIST
  unless changes.empty?
    msg = changes.map {|k| { k => { @env[k] => ENV[k] } }}.to_s
    raise 'ENV changed after freeze: ' + msg
  end
end

#freezeObject



7
8
9
10
11
# File 'lib/ice_age.rb', line 7

def freeze
  raise 'already frozen' if frozen?

  @env = ENV.to_h.freeze
end

#frozen?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/ice_age.rb', line 13

def frozen?
  !!@env
end

#restoreObject



17
18
19
20
21
# File 'lib/ice_age.rb', line 17

def restore
  raise 'not frozen' unless frozen?

  ENV.replace(@env)
end