Module: Sinatra::JSend
- Includes:
- JSON
- Defined in:
- lib/sinatra/jsend.rb
Instance Method Summary collapse
- #jsend_error(message, code = nil, data = nil) ⇒ Object
- #jsend_fail(data) ⇒ Object
- #jsend_success(data) ⇒ Object (also: #jsend_ok)
Instance Method Details
#jsend_error(message, code = nil, data = nil) ⇒ Object
17 18 19 |
# File 'lib/sinatra/jsend.rb', line 17 def jsend_error(, code = nil, data = nil) jsend_stop(json({ :status => "error", :message => , :code => code, :data => data }.keep_if{|_,v| v != nil })) end |
#jsend_fail(data) ⇒ Object
13 14 15 |
# File 'lib/sinatra/jsend.rb', line 13 def jsend_fail(data) jsend_stop(json ({ :status => "fail", :data => data })) end |
#jsend_success(data) ⇒ Object Also known as: jsend_ok
8 9 10 |
# File 'lib/sinatra/jsend.rb', line 8 def jsend_success(data) json ({ :status => "success", :data => data }) end |