Module: Waxx::Json

Extended by:
Json
Included in:
Json
Defined in:
waxx/json.rb

Overview

Waxx Copyright © 2016 ePark labs Inc. & Daniel J. Fitzpatrick <dan@eparklabs.com> All rights reserved. Released under the Apache Version 2 License. See LICENSE.txt.

Instance Method Summary collapse

Instance Method Details

#delete(x, message: {}) ⇒ Object



16
17
18
# File 'waxx/json.rb', line 16

def delete(x, message:{})
  x << {ok: true, type: message[:type], message: message[:message]}.to_json
end

#get(x, d, message: {}) ⇒ Object Also known as: post, put, patch



6
7
8
9
10
11
12
# File 'waxx/json.rb', line 6

def get(x, d, message:{})
  if PG::Result === d
    x << d.map{|r| r}.to_json
  else
    x << d.to_json
  end
end

#not_found(x, data: {}, message: {}) ⇒ Object



19
20
21
22
# File 'waxx/json.rb', line 19

def not_found(x, data:{}, message:{})
  x.res.status = 404
  x << {ok: false, type: message[:type], message: message[:message]}.to_json
end