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.



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

#identifierObject (readonly)

Returns the value of attribute identifier.



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

def identifier
  @identifier
end

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

#callObject



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