Class: SmartCredentials::Accessor
- Inherits:
-
Object
- Object
- SmartCredentials::Accessor
show all
- Defined in:
- lib/smart_credentials/accessor.rb
Instance Method Summary
collapse
Constructor Details
#initialize(path = []) ⇒ Accessor
Returns a new instance of Accessor.
5
6
7
|
# File 'lib/smart_credentials/accessor.rb', line 5
def initialize(path = [])
@path = path
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/smart_credentials/accessor.rb', line 9
def method_missing(method_name, *args, &block)
if args.empty? && !block_given?
fetch(method_name)
else
super
end
end
|
Instance Method Details
#[](key) ⇒ Object
21
22
23
|
# File 'lib/smart_credentials/accessor.rb', line 21
def [](key)
fetch(key)
end
|
#dig(*keys) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/smart_credentials/accessor.rb', line 25
def dig(*keys)
keys.reduce(self) do |acc, key|
break nil if acc.nil?
acc[key]
end
end
|
#respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean
17
18
19
|
# File 'lib/smart_credentials/accessor.rb', line 17
def respond_to_missing?(_method_name, _include_private = false)
true
end
|