Exception: ConvenientService::Service::Plugins::HasJSendResultShortSyntax::Success::Exceptions::KwargsContainJSendAndExtraKeys

Inherits:
Exception
  • Object
show all
Defined in:
lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/exceptions.rb

Instance Method Summary collapse

Methods inherited from Exception

new

Instance Method Details

#initialize_without_argumentsvoid

This method returns an undefined value.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/convenient_service/service/plugins/has_j_send_result_short_syntax/success/exceptions.rb', line 13

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