Class: ComplexConfig::Proxy
- Inherits:
-
BasicObject
- Defined in:
- lib/complex_config/proxy.rb
Instance Method Summary
collapse
Constructor Details
#initialize(env = nil) ⇒ Proxy
Returns a new instance of Proxy.
3
4
5
|
# File 'lib/complex_config/proxy.rb', line 3
def initialize(env = nil)
@env = env
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/complex_config/proxy.rb', line 20
def method_missing(name, *args)
if name =~ /\?\z/
method_name, name = name, $`
exist = ::ComplexConfig::Provider.exist?(name)
(class << self; self; end).class_eval do
define_method(method_name) do |env = nil|
if exist
__send__(name, *args)
else
nil
end
end
end
__send__(method_name, *args)
else
config = ::ComplexConfig::Provider[name]
(class << self; self; end).class_eval do
define_method(name) do |env = nil|
if env ||= @env
config[env] || ::ComplexConfig::Settings.new
else
config
end
end
end
__send__(name, *args)
end
end
|
Instance Method Details
11
12
13
|
# File 'lib/complex_config/proxy.rb', line 11
def inspect
"#<#{to_s}>"
end
|
7
8
9
|
# File 'lib/complex_config/proxy.rb', line 7
def to_s
'ComplexConfig::Proxy'
end
|