Class: VagrantRubydns::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-rubydns/store.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_fileObject

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

.hostsObject



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