Class: Teems::Services::Configuration
- Inherits:
-
Object
- Object
- Teems::Services::Configuration
- Defined in:
- lib/teems/services/configuration.rb
Overview
Manages CLI configuration stored in XDG config directory
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(paths: Support::XdgPaths.new) ⇒ Configuration
constructor
A new instance of Configuration.
- #register_warning_handler(handler) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(paths: Support::XdgPaths.new) ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 |
# File 'lib/teems/services/configuration.rb', line 7 def initialize(paths: Support::XdgPaths.new) @paths = paths @on_warning = nil @data = nil end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 |
# File 'lib/teems/services/configuration.rb', line 17 def [](key) data[key] end |
#[]=(key, value) ⇒ Object
21 22 23 24 |
# File 'lib/teems/services/configuration.rb', line 21 def []=(key, value) data[key] = value save_config end |
#register_warning_handler(handler) ⇒ Object
13 14 15 |
# File 'lib/teems/services/configuration.rb', line 13 def register_warning_handler(handler) @on_warning = handler end |
#to_h ⇒ Object
26 27 28 |
# File 'lib/teems/services/configuration.rb', line 26 def to_h data.dup end |