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

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

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.

Class Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ 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.



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

def method_missing(name, *args, &block)
  if config.respond_to?(name)
    config.public_send(name, *args, &block)
  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.



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 => e # rubocop:disable Style/RescueStandardError
        errors[setting.name] = e
      end
    end

    raise InvalidSettingsError, errors unless errors.empty?
  end
end