Class: Dry::System::Settings::DSL

Inherits:
BasicObject
Defined in:
lib/dry/system/settings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#identifierObject (readonly)

Returns the value of attribute identifier.



12
13
14
# File 'lib/dry/system/settings.rb', line 12

def identifier
  @identifier
end

#schemaObject (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

#callObject



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