Sha256: 084f9eb64af163181fa4dcc653aabed1280bfc009cb6b66799af5ed0985e3def

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module HasJSendResultShortSyntax
        module Failure
          module Commands
            class AssertKwargsContainOnlyJSendKeys < Support::Command
              ##
              # @!attribute [r] kwargs
              #   @return [Hash{Symbol => Object}]
              #
              attr_reader :kwargs

              ##
              # @param kwargs [Hash{Symbol => Object}]
              # @return [void]
              #
              def initialize(kwargs:)
                @kwargs = kwargs
              end

              ##
              # @return [void]
              # @raise [ConvenientService::Service::Plugins::HasJSendResultShortSyntax::Failure::Exceptions::KwargsContainNonJSendKey]
              #
              def call
                raise Exceptions::KwargsContainNonJSendKey.new(key: non_jsend_keys.first) if non_jsend_keys.any?
              end

              private

              ##
              # @return [Array<Symbol>]
              #
              def non_jsend_keys
                kwargs.keys - valid_jsend_keys
              end

              ##
              # @return [Array<Symbol>]
              #
              def valid_jsend_keys
                [:data, :message]
              end
            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/failure/commands/assert_kwargs_contain_only_j_send_keys.rb