Sha256: f32fc583faf01efd8bf8e3dd154b125a4cd6432667dc4c258ed3faedd48d7114
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module ConvenientService module Service module Plugins module CanHaveFallbacks class Middleware < MethodChainMiddleware intended_for [:fallback_failure_result, :fallback_error_result, :fallback_result], entity: :service ## # @return [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. # 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 private ## # @return [Symbol, nil] # def status middleware_arguments.kwargs.fetch(:status) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems