Class: OnTheSnow::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/onthesnow/config.rb
Instance Method Summary
collapse
Constructor Details
#initialize(&block) ⇒ Config
Returns a new instance of Config.
3
4
5
6
7
8
|
# File 'lib/onthesnow/config.rb', line 3
def initialize(&block)
@hash = {}
if block_given?
yield self
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/onthesnow/config.rb', line 18
def method_missing(meth, *args, &blk)
if block_given?
self[meth] = self.class.new(&blk)
else
raise "only one argument supported" if args.size > 1
return self[meth] if args.size == 0
return self[meth] = args.first
end
end
|
Instance Method Details
#[](key) ⇒ Object
10
11
12
|
# File 'lib/onthesnow/config.rb', line 10
def [](key)
@hash[key]
end
|
#[]=(key, value) ⇒ Object
14
15
16
|
# File 'lib/onthesnow/config.rb', line 14
def []=(key, value)
@hash[key] = value
end
|