Module: Sinclair::Settable
- Extended by:
- ClassMethods
- Included in:
- ChainSettable, EnvSettable
- Defined in:
- lib/sinclair/settable.rb,
lib/sinclair/settable/caster.rb,
lib/sinclair/settable/builder.rb,
lib/sinclair/settable/class_methods.rb
Overview
Module to be extended or included, allowing settings to be read from a source
Defined Under Namespace
Modules: ClassMethods Classes: Builder, Caster
Instance Method Summary collapse
-
#settable_module ⇒ Module
private
returns the settable module that the class extends.
-
#setting_with_options(*settings_name, **options) ⇒ Array<MethodDefinition>
Add setting with options.
-
#with_settings(*settings_name, **defaults) ⇒ Hash<Symbol, Object>
Adds settings.
Methods included from ClassMethods
Instance Method Details
#settable_module ⇒ Module
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.
returns the settable module that the class extends
This is used in order to find out what is the read block used by the settable
53 54 55 56 57 |
# File 'lib/sinclair/settable.rb', line 53 def settable_module @settable_module ||= singleton_class.included_modules.find do |modu| modu <= Sinclair::Settable end end |
#setting_with_options(*settings_name, **options) ⇒ Array<MethodDefinition>
Add setting with options
99 100 101 102 103 |
# File 'lib/sinclair/settable.rb', line 99 def (*settings_name, **) opts = .merge() Builder.build(self, *settings_name, **opts) end |
#with_settings(*settings_name, **defaults) ⇒ Hash<Symbol, Object>
Adds settings
77 78 79 80 81 82 83 |
# File 'lib/sinclair/settable.rb', line 77 def with_settings(*settings_name, **defaults) (*settings_name) defaults.each do |key, default| (key, default: default) end end |