module ApiRescuable

Public Class Methods

included(base) click to toggle source
# File lib/api_rescuable.rb, line 36
def self.included(base)
  base.send :extend, ClassMethods
end

Private Instance Methods

handle_forbidden_attributes(exception) click to toggle source
# File lib/api_rescuable.rb, line 16
def handle_forbidden_attributes(exception)
  render json: { description: 'Forbidden attribute(s)',
                 messages: [exception.to_s] },
         status: :bad_request
end
handle_parameter_missing(exception) click to toggle source
# File lib/api_rescuable.rb, line 22
def handle_parameter_missing(exception)
  render json: { description: 'Missing Param',
                 messages: [exception.to_s] },
         status: :bad_request
end
handle_record_invalid(exception) click to toggle source
# File lib/api_rescuable.rb, line 10
def handle_record_invalid(exception)
  render json: { description: 'Invalid entity',
                 messages: [exception.to_s] },
         status: :unprocessable_entity
end
handle_record_not_found() click to toggle source
# File lib/api_rescuable.rb, line 4
def handle_record_not_found
  render json: { description: 'Not Found',
                 messages: [] },
         status: :not_found
end
handle_unauthorized_access(exception) click to toggle source
# File lib/api_rescuable.rb, line 28
def handle_unauthorized_access(exception)
  render json: { description: 'You are not authorized for that action',
                 messages: [] },
         status: :unauthorized
end