Module: VaucharAPI::Connection::RequestNotification

Included in:
ActiveResource::Connection, VaucharAPI::Connection
Defined in:
lib/vauchar_api/connection.rb

Instance Method Summary collapse

Instance Method Details

#notify_about_request(method, path, response, arguments) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/vauchar_api/connection.rb', line 30

def notify_about_request(method, path, response, arguments)
  ActiveSupport::Notifications.instrument("request.active_resource_detailed") do |payload|
    payload[:method] = method
    payload[:path] = path
    payload[:response] = response
    payload[:data] = arguments
    p "### Notify About Request ###"
    pp payload
  end
end

#request(method, path, *arguments) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/vauchar_api/connection.rb', line 21

def request(method, path, *arguments)
  super.tap do |response|
    notify_about_request(method, path, response, arguments)
  end
rescue => e
  notify_about_request(method, path, e.response, arguments) if e.respond_to?(:response)
  raise
end