class Vacuum::Response

A wrapper around the API response

Attributes

parser[RW]

@return [nil,.parse] an optional custom parser

parser[W]

@return [nil,.parse] an optional custom parser

Public Instance Methods

parse() click to toggle source

Parses the response body

@note Delegates to {#to_h} if no custom parser is set

# File lib/vacuum/response.rb, line 37
def parse
  parser ? parser.parse(body) : to_h
end
parser() click to toggle source

@!attribute [r] parser @return [nil,.parse] an optional custom parser

# File lib/vacuum/response.rb, line 30
def parser
  @parser || self.class.parser
end
to_h() click to toggle source

Casts body to Hash

@return [Hash]

# File lib/vacuum/response.rb, line 44
def to_h
  JSON.parse(body)
end