Class: Loggun::OrderedOptions
- Inherits:
-
Hash
- Object
- Hash
- Loggun::OrderedOptions
show all
- Defined in:
- lib/loggun/ordered_options.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/loggun/ordered_options.rb', line 19
def method_missing(name, *args)
name_string = +name.to_s
if name_string.chomp!('=')
self[name_string] = args.first
else
bangs = name_string.chomp!('!')
if bangs
self[name_string].presence || raise(KeyError, ":#{name_string} is blank")
else
self[name_string]
end
end
end
|
Instance Method Details
#[](key) ⇒ Object
15
16
17
|
# File 'lib/loggun/ordered_options.rb', line 15
def [](key)
super(key.to_sym)
end
|
#[]=(key, value) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/loggun/ordered_options.rb', line 6
def []=(key, value)
if self[key.to_sym].is_a?(Loggun::OrderedOptions) &&
[true, false].include?(value)
return self[key.to_sym][:enable] = value
end
super(key.to_sym, value)
end
|
#respond_to_missing?(_name, _include_private) ⇒ Boolean
34
35
36
|
# File 'lib/loggun/ordered_options.rb', line 34
def respond_to_missing?(_name, _include_private)
true
end
|