Sha256: 4b88bd8bdbb3e248144137297657f27ce5afac9aa3432c031a1c1858731881fe

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Dry
  module System
    module ProviderSources
      module Settings
        class Source < Dry::System::Provider::Source
          setting :store

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

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

          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
        end
      end
    end
  end
end

Dry::System.register_provider_source(
  :settings,
  group: :dry_system,
  source: Dry::System::ProviderSources::Settings::Source
)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dry-system-1.1.1 lib/dry/system/provider_sources/settings.rb
dry-system-1.1.0 lib/dry/system/provider_sources/settings.rb
dry-system-1.1.0.beta2 lib/dry/system/provider_sources/settings.rb
dry-system-1.1.0.beta1 lib/dry/system/provider_sources/settings.rb
dry-system-1.0.1 lib/dry/system/provider_sources/settings.rb
dry-system-1.0.0 lib/dry/system/provider_sources/settings.rb
dry-system-1.0.0.rc1 lib/dry/system/provider_sources/settings.rb