Class: Zenflow::Config
- Inherits:
-
Object
- Object
- Zenflow::Config
- Defined in:
- lib/zenflow/helpers/config.rb
Constant Summary collapse
- CONFIG_FILE =
"#{Dir.pwd}/.zenflow"
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/zenflow/helpers/config.rb', line 4 def config @config end |
Class Method Details
.[](key) ⇒ Object
19 20 21 22 |
# File 'lib/zenflow/helpers/config.rb', line 19 def [](key) load! @config[key.to_s] end |
.[]=(key, value) ⇒ Object
24 25 26 27 28 |
# File 'lib/zenflow/helpers/config.rb', line 24 def []=(key, value) load! @config[key.to_s] = value save! end |
.configured? ⇒ Boolean
30 31 32 |
# File 'lib/zenflow/helpers/config.rb', line 30 def configured? File.exist?(CONFIG_FILE) end |
.load! ⇒ Object
8 9 10 11 |
# File 'lib/zenflow/helpers/config.rb', line 8 def load! @config = {} @config = YAML.load_file(CONFIG_FILE) if configured? end |
.save! ⇒ Object
13 14 15 16 17 |
# File 'lib/zenflow/helpers/config.rb', line 13 def save! File.open(CONFIG_FILE, "w") do |out| YAML.dump(@config, out) end end |