class Dotenv::Environment
This class inherits from Hash and represents the environment into which Dotenv
will load key value pairs from a file.
Attributes
filename[R]
Public Class Methods
new(filename, is_load = false)
click to toggle source
# File lib/dotenv/environment.rb, line 7 def initialize(filename, is_load = false) @filename = filename load(is_load) end
Public Instance Methods
apply()
click to toggle source
# File lib/dotenv/environment.rb, line 20 def apply each { |k, v| ENV[k] ||= v } end
apply!()
click to toggle source
# File lib/dotenv/environment.rb, line 24 def apply! each { |k, v| ENV[k] = v } end
load(is_load = false)
click to toggle source
# File lib/dotenv/environment.rb, line 12 def load(is_load = false) update Parser.call(read, is_load) end
read()
click to toggle source
# File lib/dotenv/environment.rb, line 16 def read File.open(@filename, "rb:bom|utf-8", &:read) end