Sha256: 3cc0a4311b224fa596bd5de4f4bb17a6ef16daa0f0e1a2f750e0702c91feb1fe

Contents?: true

Size: 776 Bytes

Versions: 2

Compression:

Stored size: 776 Bytes

Contents

module Rubai
  class Response
    attr_reader :status

    def initialize(status = 200, content_type = "text/html", body=[])
      @status = status
      self.content_type= content_type
      @body = body
    end

    def self.new_with_body body
      self.new 200, "text/html", [body]
    end

    def body
      @body ||= []
    end

    def <<(body_text)
      body << body_text
    end

    def content_type=(content_type)
      self["Content-Type"] = content_type
    end

    def content_type
      self["Content-Type"]
    end

    def status=(status)
      @status = status
    end

    def headers
      @headers ||= {}
    end

    private

    def [](header)
      headers[header]
    end

    def []=(header, value)
      headers[header] = value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubai-0.1.2 lib/rubai/response.rb
rubai-0.1.1 lib/rubai/response.rb