Class: Muzak::Config
- Inherits:
-
Object
- Object
- Muzak::Config
- Defined in:
- lib/muzak/config.rb
Overview
Muzak's static configuration dumping ground. Key-value pairs are loaded from CONFIG_FILE and translated from kebab-case to snake_case methods.
Constant Summary collapse
- DEFAULT_CONFIG =
{ # core defaults "debug" => false, "verbose" => true, "music" => File.("~/music"), "player" => "mpv", "jukebox-size" => 100, # client/daemon defaults "daemon-port" => 2669, "daemon-host" => "localhost", }.freeze
Class Method Summary collapse
-
.method_missing(method, *args) ⇒ false
Catches all undefined configuration keys and defaults them to false.
-
.plugin?(pname) ⇒ Boolean
Whether or not the given plugin is configured.
-
.sync! ⇒ void
Synchronizes the in-memory configuration with CONFIG_FILE.
Class Method Details
.method_missing(method, *args) ⇒ false
Catches all undefined configuration keys and defaults them to false.
15 16 17 |
# File 'lib/muzak/config.rb', line 15 def self.method_missing(method, *args) false end |
.plugin?(pname) ⇒ Boolean
Note:
the truth-value of this method is used to determine which plugins should be loaded.
Returns whether or not the given plugin is configured.
28 29 30 |
# File 'lib/muzak/config.rb', line 28 def self.plugin?(pname) respond_to? "plugin_#{pname}" end |
.sync! ⇒ void
This method returns an undefined value.
Synchronizes the in-memory configuration with Muzak::CONFIG_FILE.
21 22 23 |
# File 'lib/muzak/config.rb', line 21 def self.sync! File.open(CONFIG_FILE, "w") { |io| io.write @config.to_yaml } end |