Class: Unfig::EnvLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/unfig/env_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(params:, env:) ⇒ EnvLoader

Returns a new instance of EnvLoader.



3
4
5
6
# File 'lib/unfig/env_loader.rb', line 3

def initialize(params:, env:)
  @params = params
  @env = env
end

Instance Method Details

#readObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/unfig/env_loader.rb', line 8

def read
  return @_read if defined?(@_read)

  @_read = {}
  params.params.each do |p|
    next unless p.enabled.include?("env")

    reader = EnvReader.new(param: p, env: env)
    @_read[p.name] = reader.value if reader.supplied?
  end
  @_read
end