Class: VagrantPlugins::Skytap::Properties
- Inherits:
-
Object
- Object
- VagrantPlugins::Skytap::Properties
show all
- Defined in:
- lib/vagrant-skytap/properties.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data_dir) ⇒ Properties
Returns a new instance of Properties.
50
51
52
53
|
# File 'lib/vagrant-skytap/properties.rb', line 50
def initialize(data_dir)
@properties = self.class.read(data_dir)
@data_dir = data_dir
end
|
Instance Attribute Details
Returns the value of attribute data_dir.
29
30
31
|
# File 'lib/vagrant-skytap/properties.rb', line 29
def data_dir
@data_dir
end
|
#properties ⇒ Object
Returns the value of attribute properties.
28
29
30
|
# File 'lib/vagrant-skytap/properties.rb', line 28
def properties
@properties
end
|
Class Method Details
31
32
33
|
# File 'lib/vagrant-skytap/properties.rb', line 31
def self.filename
raise NotImplementedError.new('Must override')
end
|
.read(data_dir) ⇒ Object
35
36
37
38
39
40
|
# File 'lib/vagrant-skytap/properties.rb', line 35
def self.read(data_dir)
file = data_dir.join(filename)
if file.exist?
YAML.load_file(file)
end
end
|
.write(data_dir, properties = {}) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/vagrant-skytap/properties.rb', line 42
def self.write(data_dir, properties={})
existing_props = read(data_dir) || {}
props = existing_props.merge(properties)
IO.write(data_dir.join(filename),
YAML.dump(props))
end
|
Instance Method Details
55
56
57
|
# File 'lib/vagrant-skytap/properties.rb', line 55
def read
self.class.read(@data_dir)
end
|
#write(properties = {}) ⇒ Object
59
60
61
|
# File 'lib/vagrant-skytap/properties.rb', line 59
def write(properties={})
self.class.write(@data_dir, properties)
end
|