Class: Gruf::Hooks::Base
- Inherits:
-
Object
- Object
- Gruf::Hooks::Base
- Includes:
- Loggable
- Defined in:
- lib/gruf/hooks/base.rb
Overview
Base class for a hook. Define before, around, outer_around, or after methods to utilize functionality.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
Options Options to use for the hook.
-
#service ⇒ Gruf::Service
readonly
Service The service to perform the hook against.
Instance Method Summary collapse
-
#initialize(service, options = {}) ⇒ Base
constructor
Initialize the hook and run setup.
-
#method_key(call_signature) ⇒ String
Parse the method signature into a service.method name format.
-
#service_key ⇒ String
Returns the service name as a translated name separated by periods.
-
#setup ⇒ Object
Method that can be used to setup the hook prior to running it.
Methods included from Loggable
Constructor Details
#initialize(service, options = {}) ⇒ Base
Initialize the hook and run setup
36 37 38 39 40 |
# File 'lib/gruf/hooks/base.rb', line 36 def initialize(service, = {}) @service = service @options = setup end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns options Options to use for the hook.
28 29 30 |
# File 'lib/gruf/hooks/base.rb', line 28 def @options end |
#service ⇒ Gruf::Service (readonly)
Returns service The service to perform the hook against.
26 27 28 |
# File 'lib/gruf/hooks/base.rb', line 26 def service @service end |
Instance Method Details
#method_key(call_signature) ⇒ String
Parse the method signature into a service.method name format
61 62 63 |
# File 'lib/gruf/hooks/base.rb', line 61 def method_key(call_signature) "#{service_key}.#{call_signature.to_s.gsub('_without_intercept', '')}" end |
#service_key ⇒ String
Returns the service name as a translated name separated by periods
52 53 54 |
# File 'lib/gruf/hooks/base.rb', line 52 def service_key service.class.name.underscore.tr('/', '.') end |
#setup ⇒ Object
Method that can be used to setup the hook prior to running it
45 46 47 |
# File 'lib/gruf/hooks/base.rb', line 45 def setup # noop end |