Class: DevSuite::Utils::Construct::Config::Settings::Base
- Inherits:
-
Object
- Object
- DevSuite::Utils::Construct::Config::Settings::Base
- Defined in:
- lib/dev_suite/utils/construct/config/settings/base.rb
Instance Method Summary collapse
- #get(*keys, default: nil) ⇒ Object
-
#initialize(settings = {}) ⇒ Base
constructor
A new instance of Base.
- #merge(options) ⇒ Object
- #reset! ⇒ Object
- #set(*keys, value) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(settings = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 |
# File 'lib/dev_suite/utils/construct/config/settings/base.rb', line 9 def initialize(settings = {}) @default_settings = settings @settings = Utils::Data.deep_merge(@default_settings, settings) end |
Instance Method Details
#get(*keys, default: nil) ⇒ Object
19 20 21 22 23 |
# File 'lib/dev_suite/utils/construct/config/settings/base.rb', line 19 def get(*keys, default: nil) key_path = extract_path_from_keys(keys) value = Utils::Data.get_value_by_path(@settings, key_path) value.nil? ? default : value end |
#merge(options) ⇒ Object
33 34 35 |
# File 'lib/dev_suite/utils/construct/config/settings/base.rb', line 33 def merge() Utils::Data.deep_merge(@settings, ) end |
#reset! ⇒ Object
25 26 27 |
# File 'lib/dev_suite/utils/construct/config/settings/base.rb', line 25 def reset! @settings = Utils::Data.deep_merge(@default_settings, {}) end |
#set(*keys, value) ⇒ Object
14 15 16 17 |
# File 'lib/dev_suite/utils/construct/config/settings/base.rb', line 14 def set(*keys, value) key_path = extract_path_from_keys(keys) Utils::Data.set_value_by_path(@settings, key_path, value) end |
#to_h ⇒ Object
29 30 31 |
# File 'lib/dev_suite/utils/construct/config/settings/base.rb', line 29 def to_h @settings end |