Class: ThemeBandit::Config
- Inherits:
-
Object
- Object
- ThemeBandit::Config
show all
- Defined in:
- lib/theme_bandit/util/configure.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data = {}) ⇒ Config
Returns a new instance of Config.
15
16
17
18
|
# File 'lib/theme_bandit/util/configure.rb', line 15
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
42
43
44
45
46
47
48
|
# File 'lib/theme_bandit/util/configure.rb', line 42
def method_missing(sym, *args)
if sym.to_s =~ /(.+)=$/
self[Regexp.last_match[1]] = args.first
else
self[sym]
end
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
13
14
15
|
# File 'lib/theme_bandit/util/configure.rb', line 13
def data
@data
end
|
Instance Method Details
#[](key) ⇒ Object
26
27
28
|
# File 'lib/theme_bandit/util/configure.rb', line 26
def [](key)
@data[key.to_sym]
end
|
#[]=(key, value) ⇒ Object
30
31
32
|
# File 'lib/theme_bandit/util/configure.rb', line 30
def []=(key, value)
@data[key.to_sym] = value
end
|
#keys ⇒ Object
34
35
36
|
# File 'lib/theme_bandit/util/configure.rb', line 34
def keys
@data.keys
end
|
#to_hash ⇒ Object
38
39
40
|
# File 'lib/theme_bandit/util/configure.rb', line 38
def to_hash
@data
end
|
#update!(data) ⇒ Object
20
21
22
23
24
|
# File 'lib/theme_bandit/util/configure.rb', line 20
def update!(data)
data.each do |key, value|
self[key.to_sym] = value
end
end
|