Class: Blix::Rest::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/blix/rest/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponse

Returns a new instance of Response.



17
18
19
20
21
# File 'lib/blix/rest/response.rb', line 17

def initialize
  @status  = 200
  @headers  = Rack::Headers.new
  @content = nil
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



15
16
17
# File 'lib/blix/rest/response.rb', line 15

def content
  @content
end

#headersObject (readonly)

Returns the value of attribute headers.



14
15
16
# File 'lib/blix/rest/response.rb', line 14

def headers
  @headers
end

#statusObject

Returns the value of attribute status.



13
14
15
# File 'lib/blix/rest/response.rb', line 13

def status
  @status
end

Instance Method Details

#set(status, content = nil, headers = nil) ⇒ Object



23
24
25
26
27
# File 'lib/blix/rest/response.rb', line 23

def set(status,content=nil,headers=nil)
  @status = status if status
  @content = [String.new(content)] if content
  @headers.merge!(headers) if headers
end

#set_options(options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/blix/rest/response.rb', line 29

def set_options(options={})
  @status = options[:status].to_i if options[:status]
  @headers.merge!(options[:headers]) if options[:headers]
  @headers['content-type'] = options[:content_type] if options[:content_type]
end