class RackRabbit::Response
Attributes
body[R]
headers[R]
status[R]
Public Class Methods
new(status, headers, body)
click to toggle source
# File lib/rack-rabbit/response.rb, line 8 def initialize(status, headers, body) @status = status @headers = headers @body = body end
Public Instance Methods
failed?()
click to toggle source
# File lib/rack-rabbit/response.rb, line 20 def failed? !succeeded? end
succeeded?()
click to toggle source
# File lib/rack-rabbit/response.rb, line 16 def succeeded? (200..299).include?(status) end
to_s()
click to toggle source
# File lib/rack-rabbit/response.rb, line 26 def to_s if succeeded? body else case status when RackRabbit::STATUS::BAD_REQUEST then "#{status} Bad Request" when RackRabbit::STATUS::NOT_FOUND then "#{status} Not Found" when RackRabbit::STATUS::FAILED then "#{status} Internal Server Error" else status.to_s end end end