Class: Kybus::Client::Validator::JSend
- Inherits:
-
Object
- Object
- Kybus::Client::Validator::JSend
- Includes:
- Exceptions
- Defined in:
- lib/kybus/client/validator/jsend.rb
Overview
Implements JSend specification on another backend calls
Constant Summary collapse
- EXCEPTION_LIST =
{ 'fail' => KybusFail, 'error' => KybusError, 'fatal' => KybusError }.freeze
Instance Method Summary collapse
Instance Method Details
#validate(response) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kybus/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(KybusError, 'Unknown Error') end end |