Module: Padrino::Response::Helpers::Simple
- Defined in:
- lib/padrino-response/helpers/simple.rb
Instance Method Summary collapse
Instance Method Details
#error_resp(obj, message = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/padrino-response/helpers/simple.rb', line 5 def error_resp(obj, =nil) status 400 if api_request content_type 'application/json' @resp ||= {} @resp[:success] = false @resp[:errors] = obj.errors if == nil @resp[:message] = if halt 400, @resp.to_json else flash[:warning] = obj.errors. if == nil flash[:warning] = if end end |
#success_resp(obj, message = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/padrino-response/helpers/simple.rb', line 20 def success_resp(obj, =nil) if api_request content_type 'application/json' @resp ||= {} @resp[:success] = true @resp[:message] = if halt 200, @resp.to_json else flash[:notice] = end end |