class Hanami::Utils::Callbacks::MethodCallback

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 @api private

Public Instance Methods

call(context, *args) click to toggle source

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.

@param context [Object] the context within we want to execute the callback. @param args [Array] an array of arguments that will be available within the execution.

@return [void, Object] It may return a value, it depends on the callback.

@since 0.1.0 @api private

@see Hanami::Utils::Callbacks::Chain#run

# File lib/hanami/utils/callbacks.rb, line 294
def call(context, *args)
  method = context.method(callback)

  if method.parameters.any?
    method.call(*args)
  else
    method.call
  end
end
eql?(other) click to toggle source

@api private

# File lib/hanami/utils/callbacks.rb, line 310
def eql?(other)
  hash == other.hash
end
hash() click to toggle source

@api private

# File lib/hanami/utils/callbacks.rb, line 305
def hash
  callback.hash
end