Class: Dry::System::Settings::DSL
- Inherits:
- BasicObject
- Defined in:
- lib/dry/system/settings.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(identifier, &block) ⇒ DSL
constructor
A new instance of DSL.
- #key(name, type) ⇒ Object
Constructor Details
#initialize(identifier, &block) ⇒ DSL
Returns a new instance of DSL.
15 16 17 18 19 |
# File 'lib/dry/system/settings.rb', line 15 def initialize(identifier, &block) @identifier = identifier @schema = {} instance_eval(&block) end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
11 12 13 |
# File 'lib/dry/system/settings.rb', line 11 def identifier @identifier end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
13 14 15 |
# File 'lib/dry/system/settings.rb', line 13 def schema @schema end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/dry/system/settings.rb', line 21 def call Core::ClassBuilder.new(name: 'Configuration', parent: Settings::Configuration).call do |klass| schema.each do |key, type| klass.setting(key, type) end end end |
#key(name, type) ⇒ Object
29 30 31 |
# File 'lib/dry/system/settings.rb', line 29 def key(name, type) schema[name] = type end |