Sha256: bce0caea05fb78c51b634c4e06a78fca776b23c2d4974db9ee6c4d31679bed5d
Contents?: true
Size: 739 Bytes
Versions: 1
Compression:
Stored size: 739 Bytes
Contents
# frozen_string_literal: true 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 attr_accessor :mash_class class << self attr_accessor :mash_class end dependency do require 'hashie/mash' self.mash_class = ::Hashie::Mash end def initialize(app = nil, options = {}) super(app) self.mash_class = options[:mash_class] || self.class.mash_class end def parse(body) case body when Hash mash_class.new(body) when Array body.map { |item| parse(item) } else body end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby_instagram-0.1.0 | lib/faraday/mashify.rb |