Sha256: b033a55c92e1bd4c58500842115b4a40eee28a29f8f9541f5ec710218d84766d
Contents?: true
Size: 670 Bytes
Versions: 2
Compression:
Stored size: 670 Bytes
Contents
require 'faraday' module FaradayMiddleware # Public: Converts parsed response bodies to a Hashie::Mash if they were of # Hash or Array type. class Mashify < Faraday::Response::Middleware class << self attr_accessor :mash_class end dependency do require 'hashie/mash' self.mash_class = ::Hashie::Mash end 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 # deprecated alias Faraday::Response::Mashify = FaradayMiddleware::Mashify
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
faraday_middleware-0.8.6 | lib/faraday_middleware/response/mashify.rb |
faraday_middleware-0.8.5 | lib/faraday_middleware/response/mashify.rb |