Class: TRex::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/t_rex/util/configure.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data = {}) ⇒ Config
Returns a new instance of Config.
19
20
21
22
|
# File 'lib/t_rex/util/configure.rb', line 19
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
46
47
48
49
50
51
52
|
# File 'lib/t_rex/util/configure.rb', line 46
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.
17
18
19
|
# File 'lib/t_rex/util/configure.rb', line 17
def data
@data
end
|
Instance Method Details
#[](key) ⇒ Object
30
31
32
|
# File 'lib/t_rex/util/configure.rb', line 30
def [](key)
@data[key.to_sym]
end
|
#[]=(key, value) ⇒ Object
34
35
36
|
# File 'lib/t_rex/util/configure.rb', line 34
def []=(key, value)
@data[key.to_sym] = value
end
|
#keys ⇒ Object
38
39
40
|
# File 'lib/t_rex/util/configure.rb', line 38
def keys
@data.keys
end
|
#to_hash ⇒ Object
42
43
44
|
# File 'lib/t_rex/util/configure.rb', line 42
def to_hash
@data
end
|
#update!(data) ⇒ Object
24
25
26
27
28
|
# File 'lib/t_rex/util/configure.rb', line 24
def update!(data)
data.each do |key, value|
self[key.to_sym] = value
end
end
|