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
33
34
35
36
|
# File 'lib/easy_config/setup.rb', line 33
def append_config_path(path)
reset if @loaded
EasyConfig::PathResolver.config_paths << path
end
|
#config_path=(path) ⇒ Object
27
28
29
30
31
|
# File 'lib/easy_config/setup.rb', line 27
def config_path=(path)
EasyConfig::PathResolver.clear!
EasyConfig::PathResolver.config_paths << path
self.reset!
end
|
#environment ⇒ Object
48
49
50
|
# File 'lib/easy_config/setup.rb', line 48
def environment
EasyConfig::Env.current
end
|
#environment=(env) ⇒ Object
52
53
54
|
# File 'lib/easy_config/setup.rb', line 52
def environment=(env)
EasyConfig::Env.set(env)
end
|
#reset ⇒ Object
38
39
40
41
|
# File 'lib/easy_config/setup.rb', line 38
def reset
EasyConfig::ConfigFile.reset!
@loaded = false
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
|