Class: Boothby::KeyRing
- Inherits:
-
Object
show all
- Includes:
- Singleton
- Defined in:
- lib/boothby/key_ring.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of KeyRing.
11
12
13
14
15
16
17
|
# File 'lib/boothby/key_ring.rb', line 11
def initialize
config_files = Dir[Rails.root.join('config/*.y{a,}ml{.erb,}')]
@configs = config_files.to_h do |config|
config_name = File.basename(config).split('.').first.to_sym
[config_name, Boothby::YAMLReader.new(config)]
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, **kwargs, &block) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/boothby/key_ring.rb', line 31
def method_missing(method_name, *arguments, **kwargs, &block)
if @configs.key?(method_name.to_sym)
@configs[method_name.to_sym]
else
super
end
end
|
Class Method Details
.method_missing(method_name, *arguments, **kwargs, &block) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/boothby/key_ring.rb', line 19
def self.method_missing(method_name, *arguments, **kwargs, &block)
if instance.respond_to?(method_name)
instance.public_send(method_name)
else
super
end
end
|
.respond_to_missing?(method_name, include_private = false) ⇒ Boolean
27
28
29
|
# File 'lib/boothby/key_ring.rb', line 27
def self.respond_to_missing?(method_name, include_private = false)
instance.respond_to?(method_name) || super
end
|
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
39
40
41
|
# File 'lib/boothby/key_ring.rb', line 39
def respond_to_missing?(method_name, include_private = false)
@configs.key?(method_name.to_sym) || super
end
|