Sha256: 635c49ff97204b836f08cb0cea45fee2bdc941cee5c9fd8f9df4cdf9b1f8ddc9

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module HasJSendResultShortSyntax
        module Error
          class Middleware < MethodChainMiddleware
            intended_for :error, entity: :service

            def next(*args, **kwargs, &block)
              Commands::AssertEitherArgsOrKwargsArePassed.call(args: args, kwargs: kwargs)

              return chain.next(**kwargs) if kwargs.any?

              Commands::AssertArgsCountLowerThanThree.call(args: args)

              return chain.next if args.none?

              return chain.next(message: args.first) if args.one?

              chain.next(message: args.first, code: args.last) # NOTE: if args.count == 2
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
convenient_service-0.13.0 lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/middleware.rb