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.
16 17 18 19 20 |
# File 'lib/dry/system/settings.rb', line 16 def initialize(identifier, &block) @identifier = identifier @schema = {} instance_eval(&block) end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
12 13 14 |
# File 'lib/dry/system/settings.rb', line 12 def identifier @identifier end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
14 15 16 |
# File 'lib/dry/system/settings.rb', line 14 def schema @schema end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/dry/system/settings.rb', line 22 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
30 31 32 |
# File 'lib/dry/system/settings.rb', line 30 def key(name, type) schema[name] = type end |