Module: Configuration::InstanceMethods
- Includes:
- Enumerable
- Defined in:
- lib/configuration.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a, &b) ⇒ Object
76
77
78
79
|
# File 'lib/configuration.rb', line 76
def method_missing m, *a, &b
return(Pure[@__parent].send m, *a, &b) rescue super if @__parent
super
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
68
69
70
|
# File 'lib/configuration.rb', line 68
def name
@name
end
|
Instance Method Details
#dup ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/configuration.rb', line 98
def dup
ret = self.class.new @name
each do |name|
val = __send__ name.to_sym
if Configuration === val
val = val.dup
val.instance_variable_set('@__parent', ret)
DSL.evaluate(ret, name.to_sym => val)
else
DSL.evaluate(ret, name.to_sym => (val.dup rescue val))
end
end
ret
end
|
#each ⇒ Object
83
84
85
|
# File 'lib/configuration.rb', line 83
def each
methods(false).each{|v| yield v }
end
|
#initialize(*argv, &block) ⇒ Object
70
71
72
73
74
|
# File 'lib/configuration.rb', line 70
def initialize *argv, &block
options = Hash === argv.last ? argv.pop : Hash.new
@name = argv.shift
DSL.evaluate(self, options, &block)
end
|
#to_hash ⇒ Object
87
88
89
90
91
92
|
# File 'lib/configuration.rb', line 87
def to_hash
inject({}){ |h,name|
val = __send__(name.to_sym)
h.update name.to_sym => Configuration === val ? val.to_hash : val
}
end
|
#update(options = {}, &block) ⇒ Object
94
95
96
|
# File 'lib/configuration.rb', line 94
def update options = {}, &block
DSL.evaluate(self, options, &block)
end
|