Class: Synthra::APIServer::RackResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/synthra/api_server.rb

Overview

Response adapter for Rack

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRackResponse

Returns a new instance of RackResponse.



702
703
704
705
706
# File 'lib/synthra/api_server.rb', line 702

def initialize
  @status = 200
  @headers = { "Content-Type" => "application/json" }
  @body = ""
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



699
700
701
# File 'lib/synthra/api_server.rb', line 699

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



700
701
702
# File 'lib/synthra/api_server.rb', line 700

def headers
  @headers
end

#statusObject

Returns the value of attribute status.



699
700
701
# File 'lib/synthra/api_server.rb', line 699

def status
  @status
end

Instance Method Details

#content_type=(type) ⇒ Object



708
709
710
# File 'lib/synthra/api_server.rb', line 708

def content_type=(type)
  @headers["Content-Type"] = type
end

#json(data) ⇒ Object



712
713
714
715
# File 'lib/synthra/api_server.rb', line 712

def json(data)
  @headers["Content-Type"] = "application/json"
  @body = JSON.pretty_generate(data)
end