Sha256: 33d6d65eb9cb399c9630a4c37f8eb801caa58600e9d508c3fd789f3bb343f3bb

Contents?: true

Size: 724 Bytes

Versions: 4

Compression:

Stored size: 724 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module RaisesOnNotResultReturnValue
        class Middleware < MethodChainMiddleware
          include Support::DependencyContainer::Import

          import :"commands.is_result?", from: Service::Plugins::HasJSendResult::Container

          intended_for any_method, entity: :service

          def next(...)
            original_result = chain.next(...)

            return original_result if commands.is_result?(original_result)

            ::ConvenientService.raise Exceptions::ReturnValueNotKindOfResult.new(service: entity, result: original_result, method: method)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/service/plugins/raises_on_not_result_return_value/middleware.rb
convenient_service-0.19.0 lib/convenient_service/service/plugins/raises_on_not_result_return_value/middleware.rb
convenient_service-0.18.0 lib/convenient_service/service/plugins/raises_on_not_result_return_value/middleware.rb
convenient_service-0.17.0 lib/convenient_service/service/plugins/raises_on_not_result_return_value/middleware.rb