Class: Soapstone::Config::Configuration
- Inherits:
-
Object
- Object
- Soapstone::Config::Configuration
- Defined in:
- lib/soapstone/config/configuration.rb
Constant Summary collapse
- DEFAULT_CONFIG =
{}.with_indifferent_access
Instance Method Summary collapse
- #get(*keys) ⇒ Object
-
#initialize(config = DEFAULT_CONFIG) ⇒ Configuration
constructor
A new instance of Configuration.
- #set(value:, path:) ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(config = DEFAULT_CONFIG) ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 |
# File 'lib/soapstone/config/configuration.rb', line 6 def initialize(config = DEFAULT_CONFIG) @config = config.with_indifferent_access end |
Instance Method Details
#get(*keys) ⇒ Object
10 11 12 |
# File 'lib/soapstone/config/configuration.rb', line 10 def get(*keys) config.dig(*keys) end |
#set(value:, path:) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/soapstone/config/configuration.rb', line 14 def set(value:, path:) current = config path[0...-1].each do |key| current[key] ||= {}.with_indifferent_access current = current[key] end current[path.last] = value config end |
#to_yaml ⇒ Object
24 25 26 |
# File 'lib/soapstone/config/configuration.rb', line 24 def to_yaml config.to_yaml end |