Class: Lab419::Config::Data
- Inherits:
-
Object
- Object
- Lab419::Config::Data
show all
- Extended by:
- Forwardable
- Defined in:
- lib/lab419/config/data.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &blk) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/lab419/config/data.rb', line 26
def method_missing name, *args, &blk
if blk.nil? && args.size == 1 && /=\z/ === name then
return self[ name[0..-2] ] = args.first
end
return super( name, *args, &blk ) unless args.empty?
@store.fetch( name ){ @store[ name ] = self.class.new( overrideable: @overrideable ) }.
tap do | ele |
blk[ ele ] if blk
end
end
|
Instance Method Details
#[](key) ⇒ Object
9
10
11
|
# File 'lib/lab419/config/data.rb', line 9
def [] key
@store[ key.to_sym ]
end
|
#[]=(key, val) ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/lab419/config/data.rb', line 12
def []= key, val
case key
when String
store_value val, key.split(".")
when Symbol
@store[ key ] = val
end
end
|