Class: Dry::System::ProviderSources::Settings::Config Private

Inherits:
Object
  • Object
show all
Includes:
Configurable
Defined in:
lib/dry/system/provider_sources/settings/config.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Class Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



58
59
60
61
62
63
64
# File 'lib/dry/system/provider_sources/settings/config.rb', line 58

def method_missing(name, ...)
  if config.respond_to?(name)
    config.public_send(name, ...)
  else
    super
  end
end

Class Method Details

.load(root:, env:, loader: Loader) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dry/system/provider_sources/settings/config.rb', line 30

def self.load(root:, env:, loader: Loader)
  loader = loader.new(root: root, env: env)

  new.tap do |settings_obj|
    errors = {}

    settings.to_a.each do |setting|
      value = loader[setting.name.to_s.upcase]

      begin
        if value
          settings_obj.config.public_send(:"#{setting.name}=", value)
        else
          settings_obj.config[setting.name]
        end
      rescue => exception # rubocop:disable Style/RescueStandardError
        errors[setting.name] = exception
      end
    end

    raise InvalidSettingsError, errors unless errors.empty?
  end
end