Class: Dotenv::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/keyth/dotenv.rb

Overview

The two apply functions are all that need to be overwritten

Instance Method Summary collapse

Instance Method Details

#applyObject

sets all environment variables that are keyth: links with the appropriate key value, sets all missing env variables otherwise



8
9
10
11
12
13
14
15
16
# File 'lib/keyth/dotenv.rb', line 8

def apply
  each do |k, v|
    if v =~ /^keyth\:(.*)/
      ENV[k] = Keyth.get_key_safe(Regexp.last_match[1]) || ''
    else
      ENV[k] ||= v
    end
  end
end

#apply!Object

sets all environment variables that are keyth: links with the appropriate key value, overwrites all env variables with the contents from .env otherwise



21
22
23
24
25
26
27
28
29
# File 'lib/keyth/dotenv.rb', line 21

def apply!
  each do |k, v|
    if v =~ /^keyth\:(.*)/
      ENV[k] = Keyth.get_key_safe(Regexp.last_match[1]) || ''
    else
      ENV[k] = v
    end
  end
end