Sha256: 267343f62c4c19f41672a4f6797b6374a6d1c1fed46e4db274880c9297fe55a2

Contents?: true

Size: 457 Bytes

Versions: 4

Compression:

Stored size: 457 Bytes

Contents

require 'faraday'

module Faraday
  class Response::Mashify < Response::Middleware
    dependency 'hashie/mash'

    class << self
      attr_accessor :mash_class
    end

    self.mash_class = ::Hashie::Mash

    def parse(body)
      case body
      when Hash
        self.class.mash_class.new(body)
      when Array
        body.map { |item| item.is_a?(Hash) ? self.class.mash_class.new(item) : item }
      else
        body
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
faraday_middleware-0.7.0 lib/faraday/response/mashify.rb
faraday_middleware-0.7.0.rc1 lib/faraday/response/mashify.rb
faraday_middleware-0.6.5 lib/faraday/response/mashify.rb
faraday_middleware-0.6.3 lib/faraday/response/mashify.rb