Class: Microcon::Response

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

Overview

< BasicRequest

Instance Method Summary collapse

Constructor Details

#initialize(status:, body: {}, headers: {}) ⇒ Response

Returns a new instance of Response.



4
5
6
7
8
# File 'lib/microcon/response.rb', line 4

def initialize(status:, body: {}, headers: {})
  @status = status
  @body = encode(body)
  @headers = headers.merge Rack::CONTENT_TYPE => "application/json; charset=utf-8"
end

Instance Method Details

#encode(body) ⇒ Object



10
11
12
13
# File 'lib/microcon/response.rb', line 10

def encode(body)
  # TODO transformation
  Oj.dump(body)
end

#to_rackObject



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

def to_rack
  [@status, @headers, [@body]]
end