class Namira::Response
HTTP response
Attributes
method[R]
redirect_count[R]
url[R]
Public Class Methods
new(method, url, redirect_count, backing)
click to toggle source
Create a new {Namira::Response}
# File lib/namira/response.rb, line 19 def initialize(method, url, redirect_count, backing) @method = method @url = url @redirect_count = redirect_count @backing = backing end
serialized(raw_response)
click to toggle source
# File lib/namira/response.rb, line 13 def self.serialized(raw_response) Namira::Async::Serializer.unserialize_response(raw_response) end
Public Instance Methods
from_json()
click to toggle source
@return [Hash, Array] Parse the response body as JSON
# File lib/namira/response.rb, line 28 def from_json @from_json ||= JSON.parse(@backing.body) end
method_missing(name, *args)
click to toggle source
Proxies methods to the backing object
Calls superclass method
# File lib/namira/response.rb, line 46 def method_missing(name, *args) if @backing.respond_to?(name) @backing.send(name, *args) else super end end
ok?()
click to toggle source
@return [Bool] If the response status 2xx
# File lib/namira/response.rb, line 40 def ok? (200...300).cover?(@backing.status) end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/namira/response.rb, line 54 def respond_to_missing?(method_name, include_private = false) @backing.respond_to?(method_name) || super end
to_s()
click to toggle source
@return [String] Returns the response as a string
# File lib/namira/response.rb, line 34 def to_s @backing.to_s end