Class: Eventify::Configuration

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

Constant Summary collapse

PATH =
File.expand_path(File.join(ENV["HOME"], "/.eventify/config.yaml"))

Instance Method Summary collapse

Constructor Details

#initialize(configuration = {}) ⇒ Configuration

Returns a new instance of Configuration.



7
8
9
# File 'lib/eventify/configuration.rb', line 7

def initialize(configuration = {})
  @configuration = default_configuration.merge(load).merge(configuration)
end

Instance Method Details

#[](key) ⇒ Object



17
18
19
# File 'lib/eventify/configuration.rb', line 17

def [](key)
  @configuration[key]
end

#saveObject



11
12
13
14
15
# File 'lib/eventify/configuration.rb', line 11

def save
  FileUtils.mkdir_p File.dirname(PATH)
  @configuration[:subscribers] = [@configuration[:subscribers]].flatten
  File.open(PATH, "w") { |f| f.write YAML.dump(@configuration) }
end