lib/dry/configurable/class_methods.rb in dry-configurable-0.12.1 vs lib/dry/configurable/class_methods.rb in dry-configurable-0.13.0
- old
+ new
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'set'
+require "set"
-require 'dry/configurable/constants'
-require 'dry/configurable/dsl'
-require 'dry/configurable/methods'
-require 'dry/configurable/settings'
+require "dry/configurable/constants"
+require "dry/configurable/dsl"
+require "dry/configurable/methods"
+require "dry/configurable/settings"
module Dry
module Configurable
module ClassMethods
include Methods
@@ -16,29 +16,31 @@
def inherited(klass)
super
parent_settings = (respond_to?(:config) ? config._settings : _settings)
- klass.instance_variable_set('@_settings', parent_settings)
+ klass.instance_variable_set("@_settings", parent_settings)
end
# Add a setting to the configuration
#
- # @param [Mixed] key
+ # @param [Mixed] name
# The accessor key for the configuration value
# @param [Mixed] default
- # The default config value
- #
+ # Default value for the setting
+ # @param [#call] constructor
+ # Transformation given value will go through
+ # @param [Boolean] reader
+ # Whether a reader accessor must be created
# @yield
- # If a block is given, it will be evaluated in the context of
- # a new configuration class, and bound as the default value
+ # A block can be given to add nested settings.
#
# @return [Dry::Configurable::Config]
#
# @api public
- def setting(*args, &block)
- setting = __config_dsl__.setting(*args, &block)
+ def setting(*args, **options, &block)
+ setting = __config_dsl__.setting(*args, **options, &block)
_settings << setting
__config_reader__.define(setting.name) if setting.reader?
@@ -72,10 +74,10 @@
@config ||= Config.new(_settings)
end
# @api private
def __config_dsl__
- @dsl ||= DSL.new
+ @__config_dsl__ ||= DSL.new
end
# @api private
def __config_reader__
@__config_reader__ ||=