Class: RestClient::Jogger::Action
- Inherits:
-
Object
- Object
- RestClient::Jogger::Action
- Includes:
- ActiveModel::Model
- Defined in:
- lib/rest_client/jogger/action.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#notifier ⇒ Object
Returns the value of attribute notifier.
Instance Method Summary collapse
- #call(name, start, finish, id, payload) ⇒ Object
-
#initialize(args = {}) ⇒ Action
constructor
A new instance of Action.
- #template ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Action
Returns a new instance of Action.
7 8 9 10 |
# File 'lib/rest_client/jogger/action.rb', line 7 def initialize(args = {}) self.logger = args.fetch :logger super end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/rest_client/jogger/action.rb', line 5 def logger @logger end |
#notifier ⇒ Object
Returns the value of attribute notifier.
5 6 7 |
# File 'lib/rest_client/jogger/action.rb', line 5 def notifier @notifier end |
Instance Method Details
#call(name, start, finish, id, payload) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rest_client/jogger/action.rb', line 16 def call(name, start, finish, id, payload) start_time = payload.fetch(:start_time) render_params = { args: payload, payload: filter(payload), verify_ssl: payload[:verify_ssl], read_timeout: payload.fetch(:timeout) { payload[:read_timeout] }, open_timeout: payload.fetch(:timeout) { payload[:open_timeout] }, event_id: id, timestamp: start, time_elapsed: (finish - start_time).round(10), ip_address: ip_address } json = template.render nil, render_params name =~ /error/ ? logger.error(json) : logger.debug(json) rescue StandardError => e notifier.error e, payload: payload end |
#template ⇒ Object
35 36 37 |
# File 'lib/rest_client/jogger/action.rb', line 35 def template raise NotImplementedError, 'define a #template method in a subclass' end |