Class: Respo::Errors::Base

Inherits:
Response show all
Includes:
Helpers
Defined in:
lib/respo/errors/base.rb

Direct Known Subclasses

Create, Destroy, Index, Show, Update

Instance Attribute Summary

Attributes inherited from Response

#record, #root, #view

Instance Method Summary collapse

Methods included from Helpers

#action_name, #camelize, pluralize, singularize

Methods inherited from Response

call, #initialize, #serializer

Constructor Details

This class inherits a constructor from Respo::Response

Instance Method Details

#callObject



8
9
10
# File 'lib/respo/errors/base.rb', line 8

def call
  { json: { errors: @record.errors.full_messages }, status: status_code }
end

#status_codeObject



12
13
14
# File 'lib/respo/errors/base.rb', line 12

def status_code
  Respo::Constants::STATUSES.dig(action_name(self), :error).to_sym
end