Class: Drawbridge::Config
- Inherits:
-
Object
- Object
- Drawbridge::Config
show all
- Defined in:
- lib/drawbridge/config.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data = {}) ⇒ Config
Returns a new instance of Config.
4
5
6
7
|
# File 'lib/drawbridge/config.rb', line 4
def initialize(data={})
@data = {}
update!(data)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/drawbridge/config.rb', line 31
def method_missing(sym, *args)
if sym.to_s =~ /(.+)=$/
self[$1] = args.first
else
self[sym]
end
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3
4
5
|
# File 'lib/drawbridge/config.rb', line 3
def data
@data
end
|
Instance Method Details
#[](key) ⇒ Object
15
16
17
|
# File 'lib/drawbridge/config.rb', line 15
def [](key)
@data[key.to_sym]
end
|
#[]=(key, value) ⇒ Object
19
20
21
|
# File 'lib/drawbridge/config.rb', line 19
def []=(key, value)
@data[key.to_sym] = value
end
|
#keys ⇒ Object
23
24
25
|
# File 'lib/drawbridge/config.rb', line 23
def keys
@data.keys
end
|
#to_hash ⇒ Object
27
28
29
|
# File 'lib/drawbridge/config.rb', line 27
def to_hash
@data
end
|
#update!(data) ⇒ Object
9
10
11
12
13
|
# File 'lib/drawbridge/config.rb', line 9
def update!(data)
data.each do |key, value|
self[key.to_sym] = value
end
end
|