Module: PuppetX::Practicalclouds::Storable

Defined in:
lib/puppet_x/practicalclouds/storable.rb

Constant Summary collapse

YAMLFILE =
"#{Puppet[:confdir]}/aws.yaml"

Class Method Summary collapse

Class Method Details

.load(type) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/puppet_x/practicalclouds/storable.rb', line 13

def self.load(type)
	if File.exists?(YAMLFILE)
		hash = {}
		yamlf = YAML::load(File.open(YAMLFILE))
		if (yamlf[type])
			hash = yamlf[type].clone
		end
	end
	hash
end

.store(type, hash) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/puppet_x/practicalclouds/storable.rb', line 24

def self.store(type,hash)
	outhash = {}
	if File.exists?(YAMLFILE)
		outhash = YAML::load(File.open(YAMLFILE))
	end
	outhash[type] = hash
	File.open(YAMLFILE,'w+') {|f| f.write(outhash.to_yaml) }
end