Class: RrxConfig::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rrx_config/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.hash_data(hash) ⇒ Object



39
40
41
# File 'lib/rrx_config/configuration.rb', line 39

def hash_data(hash)
  Data.define(*hash.keys).new(**hash.transform_values { |v| v.is_a?(Hash) ? hash_data(v) : v })
end

Instance Method Details

#currentData

Returns:

  • (Data)


13
14
15
# File 'lib/rrx_config/configuration.rb', line 13

def current
  @current ||= read
end

#readObject



17
18
19
20
21
22
# File 'lib/rrx_config/configuration.rb', line 17

def read
  # Take the first source that returns a value
  @current = sources.inject(nil) do |current, source|
    current || source.new.read
  end || default_config
end