Sha256: 519e5c2e5abb8298c69b58ac77ba7065f87a6ccdba736f7aff68be1fad60b609

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

module Crystal
  class Response
    attr_accessor :status, :headers, :body
    # attr_accessor :error # for specs
    
    def initialize
      @status, @headers, @body = 200, {}, ""
    end
    
    def write str
      body << str
    end      

    def content_type= type; headers["Content-Type"] = type end
    def content_type; headers["Content-Type"] end
    def content_type?; !!content_type end
    
    def location; headers['Location'] end
    def location= location; headers['Location'] = location end
    
    def to_a
      [status, headers, body]
    end 
    
    def inspect
      to_a.inspect
    end
    
    def == other
      super(other) || to_a == other
    end
    
    def empty?
      body.empty?
    end
    alias_method :blank?, :empty?
    
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
crystal-0.0.13 lib/crystal/http/support/rack/response.rb
crystal-0.0.12 lib/crystal/http/support/rack/response.rb
crystal_ext-0.0.11 lib/crystal/http/support/rack/response.rb