Sha256: 031474d56d1320903cfd59e3dbeda814599f095a7b9a1eae5fa91248c6a895ca

Contents?: true

Size: 493 Bytes

Versions: 10

Compression:

Stored size: 493 Bytes

Contents

# encoding: utf-8

require 'faraday'

module Github
  class Response::Mashify < Faraday::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 # Github

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
github_api-0.3.2 lib/github_api/response/mashify.rb
github_api-0.3.1 lib/github_api/response/mashify.rb
github_api-0.3.0 lib/github_api/response/mashify.rb
github_api-0.2.2 lib/github_api/response/mashify.rb
github_api-0.2.1 lib/github_api/response/mashify.rb
github_api-0.2.0 lib/github_api/response/mashify.rb
github_api-0.1.2 lib/github_api/response/mashify.rb
github_api-0.1.1 lib/github_api/response/mashify.rb
github_api-0.1.0 lib/github_api/response/mashify.rb
github_api-0.1.0.pre lib/github_api/response/mashify.rb