Class: Disloku::Config::NamedConfigStore

Inherits:
Object
  • Object
show all
Defined in:
lib/disloku/config/NamedConfigStore.rb

Direct Known Subclasses

ConnectionStore, MappingStore

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ NamedConfigStore

Returns a new instance of NamedConfigStore.



8
9
10
11
12
13
# File 'lib/disloku/config/NamedConfigStore.rb', line 8

def initialize(config = nil)
	@store = {}
	if (!config.nil?)
		load(config)
	end
end

Instance Method Details

#add(name, yamlConfig) ⇒ Object



23
24
25
# File 'lib/disloku/config/NamedConfigStore.rb', line 23

def add(name, yamlConfig)
	@store[name] = transformConfig(yamlConfig)
end

#get(name) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/disloku/config/NamedConfigStore.rb', line 15

def get(name)
	if (@store.has_key?(name))
		return @store[name]
	else
		raise DislokuError.new("There is no stored object with the name '#{name}' in this store")
	end
end

#load(config) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/disloku/config/NamedConfigStore.rb', line 27

def load(config)
	if (!config.nil?)
		config.value().each_key() do |key|
			add(key, config[key])
		end
	end
end

#transformConfig(yamlConfig) ⇒ Object



35
36
37
# File 'lib/disloku/config/NamedConfigStore.rb', line 35

def transformConfig(yamlConfig)
	return yamlConfig
end