Module: FWToolkit::ConfigFile
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
31
32
33
|
# File 'lib/fwtoolkit/configfile.rb', line 31
def method_missing(name, *args, &block)
config[name.to_sym] || conf_item_missing(name) if self.method_defined? :conf_item_missing
end
|
Instance Attribute Details
#default_config ⇒ Object
Returns the value of attribute default_config.
7
8
9
|
# File 'lib/fwtoolkit/configfile.rb', line 7
def default_config
@default_config
end
|
Instance Method Details
#config ⇒ Object
9
10
11
|
# File 'lib/fwtoolkit/configfile.rb', line 9
def config
@config ||= Hash.new
end
|
27
28
29
|
# File 'lib/fwtoolkit/configfile.rb', line 27
def configure
yield config
end
|
#load_config!(config_file) ⇒ Object
19
20
21
|
# File 'lib/fwtoolkit/configfile.rb', line 19
def load_config!(config_file)
load_config_hash! Hash.hash_from_yaml(config_file)
end
|
#load_config_hash!(config) ⇒ Object
13
14
15
16
17
|
# File 'lib/fwtoolkit/configfile.rb', line 13
def load_config_hash!(config)
@config = config
merge_config @default_config if @default_config
validate_config if self.method_defined? :validate_config
end
|
#merge_config(default_config) ⇒ Object
23
24
25
|
# File 'lib/fwtoolkit/configfile.rb', line 23
def merge_config(default_config)
default_config.each { |key, value| config[key] ||= value }
end
|