Class: Configgler::Config::ConfigElement
- Inherits:
-
Object
- Object
- Configgler::Config::ConfigElement
show all
- Defined in:
- lib/configgler/config.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config, element) ⇒ ConfigElement
Returns a new instance of ConfigElement.
34
35
36
37
|
# File 'lib/configgler/config.rb', line 34
def initialize(config,element)
@element = config[element.to_s]
self
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/configgler/config.rb', line 39
def method_missing(name,*args)
el = ConfigElement.new(@element,name.to_s)
if el.element.is_a?(Hash)
args.length > 0 ? get_by_array(args,el.element) : el
else
el.element
end
end
|
Instance Attribute Details
#element ⇒ Object
Returns the value of attribute element.
32
33
34
|
# File 'lib/configgler/config.rb', line 32
def element
@element
end
|
Instance Method Details
#get(*args) ⇒ Object
60
61
62
|
# File 'lib/configgler/config.rb', line 60
def get(*args)
get_by_array(args)
end
|
#get_by_array(args) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/configgler/config.rb', line 52
def get_by_array(args)
c = @element[args.shift.to_s]
until args.length == 0
c = c[args.shift.to_s]
end
c
end
|
#value ⇒ Object
48
49
50
|
# File 'lib/configgler/config.rb', line 48
def value
@element
end
|