class Cetacean::Response
Attributes
response[R]
Public Class Methods
new(response)
click to toggle source
Feed me Faraday::Response objects or things that quack like them.
# File lib/cetacean/response.rb, line 12 def initialize(response) @response = response end
Public Instance Methods
hal?()
click to toggle source
Tells you whether the response thinks it's a HAL document or not. Does no validation.
# File lib/cetacean/response.rb, line 18 def hal? response.headers['content-type'] =~ %r{\Aapplication/hal\+json} end
Private Instance Methods
hal()
click to toggle source
# File lib/cetacean/response.rb, line 24 def hal @hal ||= parse_hal end
parse_hal()
click to toggle source
# File lib/cetacean/response.rb, line 28 def parse_hal hal? ? JSON.parse(response.body) : {} rescue JSON::JSONError, TypeError {} end