Class: Philiprehberger::ConfigKit::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/philiprehberger/config_kit/loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(schema, yaml_path: nil, env: ENV) ⇒ Loader

Returns a new instance of Loader.



8
9
10
11
12
# File 'lib/philiprehberger/config_kit/loader.rb', line 8

def initialize(schema, yaml_path: nil, env: ENV)
  @schema = schema
  @yaml_path = yaml_path
  @env = env
end

Instance Method Details

#loadObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/philiprehberger/config_kit/loader.rb', line 14

def load
  values = {}

  @schema.definitions.each do |name, definition|
    value = resolve_value(name, definition)
    validate_required!(name, definition, value)
    values[name] = cast(value, definition.type, definition.element_type)
  end

  values
end