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.
18 19 20 21 22 |
# File 'lib/dry/system/settings.rb', line 18 def initialize(identifier, &block) @identifier = identifier @schema = {} instance_eval(&block) end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
14 15 16 |
# File 'lib/dry/system/settings.rb', line 14 def identifier @identifier end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
16 17 18 |
# File 'lib/dry/system/settings.rb', line 16 def schema @schema end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/dry/system/settings.rb', line 24 def call Core::ClassBuilder.new(name: 'Configuration', parent: Configuration).call do |klass| schema.each do |key, type| klass.setting(key, type) end end end |
#key(name, type) ⇒ Object
32 33 34 |
# File 'lib/dry/system/settings.rb', line 32 def key(name, type) schema[name] = type end |