Class: ConvenientService::Service::Plugins::CanHaveFallbacks::Middleware
- Inherits:
-
MethodChainMiddleware
- Object
- ConvenientService::Service::Plugins::CanHaveFallbacks::Middleware
- Defined in:
- lib/convenient_service/service/plugins/can_have_fallbacks/middleware.rb
Instance Method Summary collapse
Instance Method Details
#next ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result
Note:
Both fallback_failure_result
, fallback_error_result
and fallback_result
are always successful, that is why their statuses are pre-checked.
15 16 17 18 19 20 21 22 |
# File 'lib/convenient_service/service/plugins/can_have_fallbacks/middleware.rb', line 15 def next(...) fallback_result = chain.next(...) ::ConvenientService.raise Exceptions::ServiceFallbackReturnValueNotSuccess.new(service: entity, result: fallback_result, status: status) unless fallback_result.success? fallback_result.copy(overrides: {kwargs: {method => true}}) .tap { |result| result.success? } end |