module Dry::Configurable

A simple configuration mixin

@example class-level configuration

class App
  extend Dry::Configurable

  setting :database do
    setting :dsn, 'sqlite:memory'
  end
end

App.config.database.dsn = 'jdbc:sqlite:memory'
App.config.database.dsn
  # => "jdbc:sqlite:memory"

@example instance-level configuration

class App
  include Dry::Configurable

  setting :database
end

production = App.new
production.config.database = ENV['DATABASE_URL']
production.finalize!

development = App.new
development.config.database = 'jdbc:sqlite:memory'
development.finalize!

@api public

Shared constants

@api private

Shared errors

@api public

Constants

AlreadyIncludedError
Error
FrozenConfigError
VERSION

@api public

Public Class Methods

extended(klass) click to toggle source

@api private

Calls superclass method
# File lib/dry/configurable.rb, line 64
def self.extended(klass)
  super
  klass.extend(Extension.new)
end
included(klass) click to toggle source

@api private

Calls superclass method
# File lib/dry/configurable.rb, line 70
def self.included(klass)
  super
  klass.include(Extension.new)
end
loader() click to toggle source
# File lib/dry/configurable.rb, line 49
def self.loader
  @loader ||= Zeitwerk::Loader.new.tap do |loader|
    root = File.expand_path("..", __dir__)
    loader.tag = "dry-configurable"
    loader.inflector = Zeitwerk::GemInflector.new("#{root}/dry-configurable.rb")
    loader.push_dir(root)
    loader.ignore(
      "#{root}/dry-configurable.rb",
      "#{root}/dry/configurable/{constants,errors,version}.rb"
    )
    loader.inflector.inflect("dsl" => "DSL")
  end
end

Public Instance Methods

enable_test_interface() click to toggle source

Mixes in test interface into the configurable module

@api public

# File lib/dry/configurable/test_interface.rb, line 20
def enable_test_interface
  extend Dry::Configurable::TestInterface
end