Class: Enigma::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/enigma/response.rb

Overview

We’ll wrap the response in a Hashie::Mash subclass so that you can access the attributes as function calls

Raw response is kept in the ‘raw` attribute

Class Method Summary collapse

Class Method Details

.parse(res) ⇒ Object



10
11
12
13
14
15
# File 'lib/enigma/response.rb', line 10

def self.parse(res)
  mash = Hashie::Mash.new(JSON.parse(res.body))
  mash.raw = res
  fail mash.message.to_s if mash.info && mash.info.error
  mash
end