Sha256: a9cad632baaaf681480fbcfde151d2c9bb66f7c095501e45dab4eea2f1952f82

Contents?: true

Size: 641 Bytes

Versions: 7

Compression:

Stored size: 641 Bytes

Contents

# frozen_string_literal: true

require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/hash/conversions'
require 'faraday'
require 'faraday_middleware/response_middleware'
require 'json'

module Weneedfeed
  class FaradayResponseMiddleware < ::FaradayMiddleware::ResponseMiddleware
    define_parser do |body, options|
      options ||= {}
      options = { dasherize: false }.merge(options)
      object = ::JSON.parse(body)
      object.to_xml(options)
    end

    # @note Overriding.
    def parse_response?(env)
      env.response.headers['Content-Type'].to_s.include?('application/json')
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
weneedfeed-0.9.2 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.9.1 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.9.0 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.8.0 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.7.2 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.7.1 lib/weneedfeed/faraday_response_middleware.rb
weneedfeed-0.7.0 lib/weneedfeed/faraday_response_middleware.rb