class Trailblazer::Endpoint::Adapter::API

Public Class Methods

insert_error_handler_steps(adapter) click to toggle source
# File lib/trailblazer/endpoint/adapter.rb, line 72
def self.insert_error_handler_steps(adapter) # TODO: evaluate if needed?
  adapter = Class.new(adapter) do
    API.insert_error_handler_steps!(self)
  end
end
insert_error_handler_steps!(adapter) click to toggle source
# File lib/trailblazer/endpoint/adapter.rb, line 78
def self.insert_error_handler_steps!(adapter)
  adapter.instance_exec do
    step :handle_not_authenticated, magnetic_to: :not_authenticated, Output(:success) => Track(:not_authenticated), before: :_401_status
    step :handle_not_authorized, magnetic_to: :not_authorized, Output(:success) => Track(:not_authorized), before: :_403_status
    # step :handle_not_found, magnetic_to: :not_found, Output(:success) => Track(:not_found), Output(:failure) => Track(:not_found)
    step :handle_invalid_data, before: :_422_status, magnetic_to: :failure, Output(:success) => Track(:failure)
  end
end

Public Instance Methods

_200_status(ctx, success_status: 200, **) click to toggle source
# File lib/trailblazer/endpoint/adapter.rb, line 61
def _200_status(ctx, success_status: 200, **)
  ctx[:status] = success_status
end
_422_status(ctx, **) click to toggle source
# File lib/trailblazer/endpoint/adapter.rb, line 67
def _422_status(ctx, **)
  ctx[:status] = 422
end