Class: VagrantRubydns::Store
- Inherits:
-
Object
- Object
- VagrantRubydns::Store
- Defined in:
- lib/vagrant-rubydns/store.rb
Instance Attribute Summary collapse
-
#backing_file ⇒ Object
Returns the value of attribute backing_file.
Class Method Summary collapse
Instance Method Summary collapse
- #clear! ⇒ Object
- #delete(key) ⇒ Object
- #get(key) ⇒ Object
-
#initialize(backing_file) ⇒ Store
constructor
A new instance of Store.
- #set(key, value) ⇒ Object
Constructor Details
#initialize(backing_file) ⇒ Store
Returns a new instance of Store.
9 10 11 |
# File 'lib/vagrant-rubydns/store.rb', line 9 def initialize(backing_file) @backing_file = Pathname(backing_file) end |
Instance Attribute Details
#backing_file ⇒ Object
Returns the value of attribute backing_file.
7 8 9 |
# File 'lib/vagrant-rubydns/store.rb', line 7 def backing_file @backing_file end |
Class Method Details
.hosts ⇒ Object
3 4 5 |
# File 'lib/vagrant-rubydns/store.rb', line 3 def self.hosts @hosts ||= new(VagrantRubydns.working_dir.join('hosts.json')) end |
Instance Method Details
#clear! ⇒ Object
25 26 27 |
# File 'lib/vagrant-rubydns/store.rb', line 25 def clear! write({}) end |
#delete(key) ⇒ Object
17 18 19 |
# File 'lib/vagrant-rubydns/store.rb', line 17 def delete(key) write(current_config.reject { |k, _| k == key }) end |
#get(key) ⇒ Object
21 22 23 |
# File 'lib/vagrant-rubydns/store.rb', line 21 def get(key) current_config[key] end |
#set(key, value) ⇒ Object
13 14 15 |
# File 'lib/vagrant-rubydns/store.rb', line 13 def set(key, value) write(current_config.merge(key => value)) end |