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
- AlreadyIncluded
- Error
- FrozenConfig
- VERSION
@api public
Public Class Methods
extended(klass)
click to toggle source
@api private
Calls superclass method
# File lib/dry/configurable.rb, line 48 def self.extended(klass) super klass.extend(ClassMethods) end
included(klass)
click to toggle source
@api private
Calls superclass method
# File lib/dry/configurable.rb, line 54 def self.included(klass) raise AlreadyIncluded if klass.include?(InstanceMethods) super klass.class_eval do extend(ClassMethods) include(InstanceMethods) prepend(Initializer) class << self undef :config undef :configure end 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