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) click to toggle source
# File lib/dotenv/environment.rb, line 7
def initialize(filename)
  @filename = filename
  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() click to toggle source
# File lib/dotenv/environment.rb, line 12
def load
  update Parser.call(read)
end
read() click to toggle source
# File lib/dotenv/environment.rb, line 16
def read
  File.open(@filename, "rb:bom|utf-8", &:read)
end