Class: ConfigStore
- Inherits:
-
Object
- Object
- ConfigStore
- Defined in:
- lib/localio/config_store.rb
Constant Summary collapse
- CONFIG_FILE =
'.localio.yml'
Instance Method Summary collapse
- #get(key) ⇒ Object
- #has?(key) ⇒ Boolean
-
#initialize ⇒ ConfigStore
constructor
A new instance of ConfigStore.
- #persist ⇒ Object
- #store(key, data) ⇒ Object
Constructor Details
#initialize ⇒ ConfigStore
Returns a new instance of ConfigStore.
4 5 6 7 8 9 |
# File 'lib/localio/config_store.rb', line 4 def initialize if File.exist? CONFIG_FILE @config = YAML.load_file(CONFIG_FILE) end @config ||= Hash.new end |
Instance Method Details
#get(key) ⇒ Object
15 16 17 |
# File 'lib/localio/config_store.rb', line 15 def get(key) @config[clean_param key] end |
#has?(key) ⇒ Boolean
11 12 13 |
# File 'lib/localio/config_store.rb', line 11 def has?(key) @config.has_key?(clean_param key) end |
#persist ⇒ Object
23 24 25 26 27 |
# File 'lib/localio/config_store.rb', line 23 def persist File.open(CONFIG_FILE, 'w') do |h| h.write @config.to_yaml end end |
#store(key, data) ⇒ Object
19 20 21 |
# File 'lib/localio/config_store.rb', line 19 def store(key, data) @config[clean_param key] = data end |