Module: EasyConfig::Setup
- Included in:
- EasyConfig
- Defined in:
- lib/easy_config/setup.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
3
4
5
6
7
8
9
10
|
# File 'lib/easy_config/setup.rb', line 3
def method_missing(name)
unless @loaded
setup_config
self.send name
else
raise ConfigurationNotFound.new("Configuration for '#{name}' was not found.")
end
end
|
Instance Method Details
#add_config_method(config) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/easy_config/setup.rb', line 19
def add_config_method(config)
(class << self; self; end).instance_eval do
define_method config.name do
config.configuration
end
end
end
|
#append_config_path(path) ⇒ Object
#config_path=(path) ⇒ Object
#environment=(env) ⇒ Object
52
53
54
|
# File 'lib/easy_config/setup.rb', line 52
def environment=(env)
EasyConfig::Env.set(env)
end
|
#reset! ⇒ Object
43
44
45
46
|
# File 'lib/easy_config/setup.rb', line 43
def reset!
reset
setup_config
end
|
#setup_config ⇒ Object
12
13
14
15
16
17
|
# File 'lib/easy_config/setup.rb', line 12
def setup_config
EasyConfig::ConfigFile.all.each do |f|
add_config_method(f)
end
@loaded = true
end
|