Sha256: 23771b118ddb85c7cb60da3703f2cfa4956b18e166dda417686ded99e2e13bd4

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Service
    module Plugins
      module HasJSendResultShortSyntax
        module Success
          module Exceptions
            class KwargsContainJSendAndExtraKeys < ::ConvenientService::Exception
              ##
              # @return [void]
              #
              def initialize_without_arguments
                message = <<~TEXT
                  `kwargs` passed to `success` method contain JSend keys and extra keys. That's NOT allowed.

                  Please, consider something like:

                  # Shorter form. Assumes that all kwargs are `data`.
                  success(foo: :bar)

                  # Longer form. More explicit.
                  success(data: {foo: :bar})

                  # (Advanced) Longer form also supports any other variation of `data`, `message` and `code`...
                  success(data: {foo: :bar}, message: "foo")
                  success(data: {foo: :bar}, code: :foo)
                  success(data: {foo: :bar}, message: "foo", code: :foo)
                  success(message: "foo")
                  success(code: :foo)
                TEXT

                initialize(message)
              end
            end
          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/has_j_send_result_short_syntax/success/exceptions.rb
convenient_service-0.19.0 lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/exceptions.rb
convenient_service-0.18.0 lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/exceptions.rb
convenient_service-0.17.0 lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/exceptions.rb