Sha256: c4fa67cbad0bfb0d9966449f9a5c7f1dcfe28f53f52217ac90407222c52430f5

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 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
                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

                super(message)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
convenient_service-0.16.0 lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/exceptions.rb
convenient_service-0.15.0 lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/exceptions.rb
convenient_service-0.14.0 lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/exceptions.rb