Class: Anyway::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/anyway/env.rb

Overview

Parses environment variables and provides method-like access

Constant Summary collapse

ARRAY_RXP =

Regexp to detect array values Array value is a values that contains at least one comma and doesn’t start/end with quote

/\A[^'"].*\s*,\s*.*[^'"]\z/

Instance Method Summary collapse

Constructor Details

#initializeEnv

Returns a new instance of Env.



16
17
18
# File 'lib/anyway/env.rb', line 16

def initialize
  @data = {}
end

Instance Method Details

#clearObject



20
21
22
# File 'lib/anyway/env.rb', line 20

def clear
  @data.clear
end

#fetch(prefix) ⇒ Object



24
25
26
27
# File 'lib/anyway/env.rb', line 24

def fetch(prefix)
  @data[prefix] ||= parse_env(prefix.to_s.upcase)
  @data[prefix].deep_dup
end