class Boxxspring::Response
Attributes
body[R]
code[R]
resources[R]
Public Class Methods
new( http_response )
click to toggle source
# File lib/boxxspring/response.rb, line 9 def initialize( http_response ) @success = http_response.is_a?( Net::HTTPOK ) @code = http_response.code @resources = [] @body = decode_response_body( http_response ) if ( @body && @body.respond_to?( :keys ) ) Boxxspring::Parser.new( @body ) do | parser | @resources = parser.resources @success = !parser.type_name?( :error ) end else @success = false @resources << Boxxspring::Error.new( message: "#{@code}: #{http_response.message}." ) end end
Public Instance Methods
failure?()
click to toggle source
# File lib/boxxspring/response.rb, line 35 def failure? not @success end
success?()
click to toggle source
# File lib/boxxspring/response.rb, line 31 def success? @success end
Protected Instance Methods
decode_response_body( http_response )
click to toggle source
# File lib/boxxspring/response.rb, line 39 def decode_response_body( http_response ) body = http_response.body if body.present? JSON.parse( body ) rescue nil else nil end end