Class: Dry::System::ProviderSources::Settings::Source

Inherits:
Dry::System::Provider::Source show all
Defined in:
lib/dry/system/provider_sources/settings.rb

Constant Summary

Constants inherited from Dry::System::Provider::Source

Dry::System::Provider::Source::CALLBACK_MAP

Instance Attribute Summary

Attributes inherited from Dry::System::Provider::Source

#callbacks, #provider_container, #target_container

Instance Method Summary collapse

Methods inherited from Dry::System::Provider::Source

#after, #before, for, inherited, #initialize, inspect, #inspect, name, #run_callback, #stop, to_s

Constructor Details

This class inherits a constructor from Dry::System::Provider::Source

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dry::System::Provider::Source

Instance Method Details

#prepareObject



10
11
12
# File 'lib/dry/system/provider_sources/settings.rb', line 10

def prepare
  require "dry/system/provider_sources/settings/config"
end

#settings(&block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dry/system/provider_sources/settings.rb', line 18

def settings(&block)
  # Save the block and evaluate it lazily to allow a provider with this source
  # to `require` any necessary files for the block to evaluate correctly (e.g.
  # requiring an app-specific types module for setting constructors)
  if block
    @settings_block = block
  elsif defined? @settings_class
    @settings_class
  elsif @settings_block
    @settings_class = Class.new(Settings::Config, &@settings_block)
  end
end

#startObject



14
15
16
# File 'lib/dry/system/provider_sources/settings.rb', line 14

def start
  register(:settings, settings.load(root: target.root, env: target.config.env))
end