Class: Teems::Services::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/teems/services/configuration.rb

Overview

Manages CLI configuration stored in XDG config directory

Instance Method Summary collapse

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_hObject



26
27
28
# File 'lib/teems/services/configuration.rb', line 26

def to_h
  data.dup
end