Module: Jsender::Rack

Extended by:
Rack
Included in:
Rack
Defined in:
lib/jsender/rack.rb

Instance Method Summary collapse

Instance Method Details

#error(code: 500, flow_id: nil, message: "An error has occurred", body_as_array: false) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/jsender/rack.rb', line 5

def error(code: 500, flow_id: nil, message: "An error has occurred", body_as_array: false)
  [
    code,
    headers(flow_id: flow_id),
    body(data: Jsender::Json.error(message: message), body_as_array: body_as_array)
  ]
end

#failure(code: 400, flow_id: nil, message: "A failure has occurred", data: nil, body_as_array: false) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/jsender/rack.rb', line 13

def failure(code: 400, flow_id: nil, message: "A failure has occurred", data: nil, body_as_array: false)
  [
    code,
    headers(flow_id: flow_id),
    body(data: Jsender::Json.failure(message: message, data: data), body_as_array: body_as_array)
  ]
end

#success(code: 200, flow_id: nil, data: nil, body_as_array: false) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/jsender/rack.rb', line 21

def success(code: 200, flow_id: nil, data: nil, body_as_array: false)
  [
    code,
    headers(flow_id: flow_id),
    body(data: Jsender::Json.success(data: data), body_as_array: body_as_array)
  ]
end