class FaradayMiddleware::Mashify
Public: Converts parsed response bodies to a Hashie::Mash if they were of Hash or Array type.
Attributes
mash_class[RW]
mash_class[RW]
Private Class Methods
new(app = nil, options = {})
click to toggle source
Calls superclass method
# File lib/faraday_middleware/response/mashify.rb, line 20 def initialize(app = nil, options = {}) super(app) self.mash_class = options[:mash_class] || self.class.mash_class end
Private Instance Methods
parse(body)
click to toggle source
# File lib/faraday_middleware/response/mashify.rb, line 25 def parse(body) case body when Hash mash_class.new(body) when Array body.map { |item| parse(item) } else body end end