Class: Dry::System::Components::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/system/components/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



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

def initialize
  @settings = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, value = nil) ⇒ Object (private)



21
22
23
24
25
26
27
28
29
# File 'lib/dry/system/components/config.rb', line 21

def method_missing(meth, value = nil)
  if meth.to_s.end_with?('=')
    @settings[meth.to_s.gsub('=', '').to_sym] = value
  elsif @settings.key?(meth)
    @settings[meth]
  else
    super
  end
end

Class Method Details

.new {|config| ... } ⇒ Object

Yields:

  • (config)


5
6
7
8
9
# File 'lib/dry/system/components/config.rb', line 5

def self.new(&block)
  config = super
  yield(config) if block_given?
  config
end

Instance Method Details

#to_hashObject



15
16
17
# File 'lib/dry/system/components/config.rb', line 15

def to_hash
  @settings
end