Module: Jsender::Json
Instance Method Summary collapse
- #error(message: "An error has occurred") ⇒ Object
- #failure(message: "A failure has occurred", data: nil) ⇒ Object
- #success(data: nil) ⇒ Object
Instance Method Details
#error(message: "An error has occurred") ⇒ Object
7 8 9 10 11 12 |
# File 'lib/jsender/json.rb', line 7 def error(message: "An error has occurred") { 'status' => 'error', 'message' => }.to_json end |
#failure(message: "A failure has occurred", data: nil) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/jsender/json.rb', line 14 def failure(message: "A failure has occurred", data: nil) { 'status' => 'fail', 'data' => data || { 'message' => } }.to_json end |
#success(data: nil) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/jsender/json.rb', line 21 def success(data: nil) { 'status' => 'success', 'data' => data }.to_json end |