class HttpStub::Server::Stub::Response::TextBody

Constants

JSON_HEADERS

Attributes

headers[R]
text[R]

Public Class Methods

new(args={}) click to toggle source
# File lib/http_stub/server/stub/response/text_body.rb, line 14
def initialize(args={})
  @headers = args[:json] ? JSON_HEADERS : {}
  @text    = args[:json].try(:to_json) || args[:body] || ""
end

Public Instance Methods

serve(application, response) click to toggle source
# File lib/http_stub/server/stub/response/text_body.rb, line 19
def serve(application, response)
  application.halt(response.status, response.headers, @text)
end
to_s() click to toggle source
# File lib/http_stub/server/stub/response/text_body.rb, line 23
def to_s
  @text
end