Class: Asetus::ConfigStruct
- Inherits:
-
Object
- Object
- Asetus::ConfigStruct
show all
- Defined in:
- lib/asetus/configstruct.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/asetus/configstruct.rb', line 39
def method_missing name, *args, &block
name = name.to_s
name = args.shift if name[0..1] == '[]' arg = args.first
if name[-1..-1] == '?' if @cfg.has_key? name[0..-2]
@cfg[name[0..-2]]
else
nil
end
elsif name[-1..-1] == '=' _asetus_set name[0..-2], arg
else
_asetus_get name, arg end
end
|
Instance Method Details
#_asetus_to_hash ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/asetus/configstruct.rb', line 4
def _asetus_to_hash
hash = {}
@cfg.each do |key, value|
if value.class == ConfigStruct
value = value._asetus_to_hash
end
key = key.to_s if @key_to_s
hash[key] = value
end
hash
end
|
#each(&block) ⇒ Object
20
21
22
|
# File 'lib/asetus/configstruct.rb', line 20
def each &block
@cfg.each(&block)
end
|
#empty? ⇒ Boolean
16
17
18
|
# File 'lib/asetus/configstruct.rb', line 16
def empty?
@cfg.empty?
end
|
#has_key?(key) ⇒ Boolean
28
29
30
|
# File 'lib/asetus/configstruct.rb', line 28
def has_key? key
@cfg.has_key? key
end
|
#keys ⇒ Object
24
25
26
|
# File 'lib/asetus/configstruct.rb', line 24
def keys
@cfg.keys
end
|