class Ant::Client::Validator::JSend

Implements JSend specification on another backend calls

Constants

EXCEPTION_LIST

Public Instance Methods

validate(response) click to toggle source
# File lib/ant/client/validator/jsend.rb, line 15
def validate(response)
  case response[:status]
  when 'success'
    response[:data]
  when 'fail', 'error', 'fatal'
    exception_klass = EXCEPTION_LIST[response[:status]]
    raise exception_klass.new(response[:message],
                              response[:code],
                              response[:data])
  else
    raise(AntError, 'Unknown Error')
  end
end