Module: Dry::Configurable::ClassMethods Private
- Includes:
- Methods
- Defined in:
- lib/dry/configurable/class_methods.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #__config_build__(settings = self.settings) ⇒ Object private
- #__config_dsl__ ⇒ Object private
- #__config_extension__ ⇒ Object private
- #__config_reader__ ⇒ Object private
-
#config ⇒ Config
Return configuration.
- #inherited(subclass) ⇒ Object private
-
#setting { ... } ⇒ Dry::Configurable::Config
Add a setting to the configuration.
-
#settings ⇒ Settings
Returns the defined settings for the class.
Methods included from Methods
Instance Method Details
#__config_build__(settings = self.settings) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 |
# File 'lib/dry/configurable/class_methods.rb', line 70 def __config_build__(settings = self.settings) __config_extension__.config_class.new(settings) end |
#__config_dsl__ ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
80 81 82 83 84 85 |
# File 'lib/dry/configurable/class_methods.rb', line 80 def __config_dsl__ @__config_dsl__ ||= DSL.new( config_class: __config_extension__.config_class, default_undefined: __config_extension__.default_undefined ) end |
#__config_extension__ ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 |
# File 'lib/dry/configurable/class_methods.rb', line 75 def __config_extension__ @__config_extension__ end |
#__config_reader__ ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/dry/configurable/class_methods.rb', line 88 def __config_reader__ @__config_reader__ ||= begin reader = Module.new do def self.define(name) define_method(name) do config[name] end end end if included_modules.include?(InstanceMethods) include(reader) end extend(reader) reader end end |
#config ⇒ Config
Return configuration
65 66 67 |
# File 'lib/dry/configurable/class_methods.rb', line 65 def config @__config__ ||= __config_build__ end |
#inherited(subclass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dry/configurable/class_methods.rb', line 9 def inherited(subclass) super subclass.instance_variable_set(:@__config_extension__, __config_extension__) new_settings = settings.dup subclass.instance_variable_set(:@__settings__, new_settings) # Only classes **extending** Dry::Configurable have class-level config. When # Dry::Configurable is **included**, the class-level config method is undefined because it # resides at the instance-level instead (see `Configurable.included`). if respond_to?(:config) subclass.instance_variable_set(:@__config__, config.dup_for_settings(new_settings)) end end |
#setting { ... } ⇒ Dry::Configurable::Config
Add a setting to the configuration
41 42 43 44 45 46 47 48 49 |
# File 'lib/dry/configurable/class_methods.rb', line 41 def setting(...) setting = __config_dsl__.setting(...) settings << setting __config_reader__.define(setting.name) if setting.reader? self end |