Module: SimpleEndpoint
- Defined in:
- lib/simple_endpoint.rb,
lib/simple_endpoint/version.rb
Overview
rubocop:disable Metrics/ParameterLists
Defined Under Namespace
Modules: Controller Classes: Endpoint, OperationIsNotHandled, UnhadledResultError
Constant Summary collapse
- OPERATION_IS_NOT_HANDLER_ERROR =
'Current operation result is not handled at #default_cases method'- HANDLER_ERROR_MESSAGE =
" Please implement default_handler via case statement\n\n EXAMPLE:\n ###############################################\n\n # Can be put into ApplicationController and redefined in subclasses\n\n private\n\n def default_handler\n -> (kase, result) do\n case kase\n when :success then render :json ...\n else\n # just in case you forgot to add handler for some of case\n SimpleEndpoint::UnhadledResultError, 'Oh nooooo!!! Really???!!'\n end\n end\n end\n\n ###############################################\n\n OR\n\n You can move this logic to separate singleton class\n"- CASES_ERROR_MESSAGE =
" Please implement default cases conditions via hash\n\n EXAMPLE:\n ###############################################\n # default trailblazer-endpoint logic, you can change it\n # Can be put into ApplicationController and redefined in subclasses\n\n private\n\n def default_cases\n {\n present: -> (result) { result.success? && result[\"present\"] }\n success: -> (result) { result.success? },\n created: -> (result) { result.success? && result[\"model.action\"] == :new }\n invalid: -> (result) { result.failure? },\n not_found: -> (result) { result.failure? && result[\"result.model\"] && result[\"result.model\"].failure? },\n unauthenticated: -> (result) { result.failure? && result[\"result.policy.default\"] && result[\"result.policy.default\"].failure? }\n }\n end\n\n ###############################################\n\n OR\n\n You can move this to separate singleton class\n"- VERSION =
'1.0.2'