Module: ProviderKit::Capable
- Extended by:
- ActiveSupport::Concern
- Included in:
- NullProvider
- Defined in:
- lib/provider_kit/capable.rb
Overview
Mixin for a model to make it have the provider methods
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, **kwargs) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/provider_kit/capable.rb', line 32
def method_missing(method_name, *args, **kwargs)
if capable_of?(method_name)
if kwargs.present?
perform_capability(method_name).with_context(provider: self, **kwargs)
else
perform_capability(method_name).with_context(provider: self, **(context || {}))
end
else
super
end
end
|
Instance Method Details
#config ⇒ Object
20
21
22
|
# File 'lib/provider_kit/capable.rb', line 20
def config
registration&.config
end
|
#credentials ⇒ Object
24
25
26
|
# File 'lib/provider_kit/capable.rb', line 24
def credentials
registration&.credentials
end
|
#display_key ⇒ Object
28
29
30
|
# File 'lib/provider_kit/capable.rb', line 28
def display_key
registration&.display_key
end
|
#null? ⇒ Boolean
Null provider is a placeholder for integrations that do not need a custom provider
returns true if this is the null provider
47
48
49
|
# File 'lib/provider_kit/capable.rb', line 47
def null?
key == :null
end
|
#provider_key ⇒ Object
51
52
53
|
# File 'lib/provider_kit/capable.rb', line 51
def provider_key
key
end
|
#with_context(**context) ⇒ Object
55
56
57
58
|
# File 'lib/provider_kit/capable.rb', line 55
def with_context(**context)
self.context = context
self
end
|