Class: Hanami::Utils::Callbacks::MethodCallback Private

Inherits:
Callback
  • Object
show all
Defined in:
lib/idempotency/hanami/utils/callbacks.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Method callback

It wraps a symbol or a string representing a method name that is implemented by the context within it will be called.

Since:

  • 0.1.0

Instance Attribute Summary

Attributes inherited from Callback

#callback

Instance Method Summary collapse

Methods inherited from Callback

#initialize

Constructor Details

This class inherits a constructor from Hanami::Utils::Callbacks::Callback

Instance Method Details

#call(context, *args) ⇒ void, Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executes the callback within the given context and eventually passing the given arguments. Those arguments will be passed according to the arity of the target method.

Parameters:

  • context (Object)

    the context within we want to execute the callback.

  • args (Array)

    an array of arguments that will be available within the execution.

Returns:

  • (void, Object)

    It may return a value, it depends on the callback.

See Also:

Since:

  • 0.1.0



284
285
286
287
288
289
290
291
292
# File 'lib/idempotency/hanami/utils/callbacks.rb', line 284

def call(context, *args)
  method = context.method(callback)

  if method.parameters.any?
    method.call(*args)
  else
    method.call
  end
end

#eql?(other) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 0.1.0



300
301
302
# File 'lib/idempotency/hanami/utils/callbacks.rb', line 300

def eql?(other)
  hash == other.hash
end

#hashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



295
296
297
# File 'lib/idempotency/hanami/utils/callbacks.rb', line 295

def hash
  callback.hash
end