Class: Framework::Config
- Inherits:
-
Hash
- Object
- Hash
- Framework::Config
show all
- Defined in:
- lib/framework/config.rb
Instance Method Summary
collapse
Constructor Details
#initialize(hash) ⇒ Config
Returns a new instance of Config.
5
6
7
8
|
# File 'lib/framework/config.rb', line 5
def initialize(hash)
super()
hash.each_pair { |k, v| self[k] = v }
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/framework/config.rb', line 21
def method_missing(method_name, *args, &block)
case args.count
when 0
self[method_name]
when 1
mname = method_name.to_s
if mname.end_with?('=')
self[mname.sub('=', '').to_sym] = *args
else
super
end
else
super
end
end
|
Instance Method Details
#[](k) ⇒ Object
11
12
13
|
# File 'lib/framework/config.rb', line 11
def [](k)
super(k.to_sym)
end
|
#[]=(k, v) ⇒ Object
17
18
19
|
# File 'lib/framework/config.rb', line 17
def []=(k,v)
super(k.to_sym, wrap(v))
end
|