Class: Trailblazer::Endpoint::Adapter::API
- Defined in:
- lib/trailblazer/endpoint/adapter.rb
Overview
Web
Defined Under Namespace
Classes: Errors
Class Method Summary collapse
-
.insert_error_handler_steps(adapter) ⇒ Object
TODO: evaluate if needed?.
- .insert_error_handler_steps!(adapter) ⇒ Object
Instance Method Summary collapse
Methods inherited from Web
#_401_status, #_403_status, #_404_status, #protocol_failure
Class Method Details
.insert_error_handler_steps(adapter) ⇒ Object
TODO: evaluate if needed?
72 73 74 75 76 |
# 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) ⇒ Object
78 79 80 81 82 83 84 85 |
# 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 |
Instance Method Details
#_200_status(ctx, success_status: 200) ⇒ Object
61 62 63 |
# File 'lib/trailblazer/endpoint/adapter.rb', line 61 def _200_status(ctx, success_status: 200, **) ctx[:status] = success_status end |
#_422_status(ctx) ⇒ Object
67 68 69 |
# File 'lib/trailblazer/endpoint/adapter.rb', line 67 def _422_status(ctx, **) ctx[:status] = 422 end |