Sha256: e3ddac5c831c8c2cf5d749871f16641e2224f5a7859e46477197a95ea9fc8095

Contents?: true

Size: 957 Bytes

Versions: 35

Compression:

Stored size: 957 Bytes

Contents

require 'active_support/core_ext/module/aliasing'

module ActiveResource
  class Connection

    attr_reader :response

    def handle_response_with_response_capture(response)
      @response = handle_response_without_response_capture(response)
    end

    def request_with_detailed_log_subscriber(method, path, *arguments)
      result = request_without_detailed_log_subscriber(method, path, *arguments)
      detailed_log_subscriber(result, arguments)
      result
    rescue => e
      detailed_log_subscriber(e.response, arguments) if e.respond_to?(:response)
      raise
    end

    def detailed_log_subscriber(response, arguments)
      ActiveSupport::Notifications.instrument("request.active_resource_detailed") do |payload|
        payload[:response] = response
        payload[:data]     = arguments
      end
    end

    alias_method_chain :handle_response, :response_capture
    alias_method_chain :request, :detailed_log_subscriber
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
shopify_api-4.2.2 lib/active_resource/connection_ext.rb
shopify_api-4.2.1 lib/active_resource/connection_ext.rb
shopify_api-4.2.0 lib/active_resource/connection_ext.rb
shopify_api-4.1.1 lib/active_resource/connection_ext.rb
shopify_api-4.1.0 lib/active_resource/connection_ext.rb
shopify_api-4.0.7 lib/active_resource/connection_ext.rb
shopify_api-4.0.6 lib/active_resource/connection_ext.rb
shopify_api-4.0.5 lib/active_resource/connection_ext.rb
shopify_api-4.0.4 lib/active_resource/connection_ext.rb
shopify_api-4.0.3 lib/active_resource/connection_ext.rb
shopify_api-4.0.2 lib/active_resource/connection_ext.rb
shopify_api-4.0.1 lib/active_resource/connection_ext.rb
shopify_api-4.0.0 lib/active_resource/connection_ext.rb
shopify_api-3.2.7 lib/active_resource/connection_ext.rb
shopify_api-3.2.6 lib/active_resource/connection_ext.rb
shopify_api-3.2.5 lib/active_resource/connection_ext.rb
shopify_api-3.2.4 lib/active_resource/connection_ext.rb
shopify_api-3.2.3 lib/active_resource/connection_ext.rb
shopify_api-3.2.2 lib/active_resource/connection_ext.rb
shopify_api-3.2.1 lib/active_resource/connection_ext.rb