class Hanami::Utils::Callbacks::Callback

Proc callback It wraps an object that responds to call

@since 0.1.0 @api private

Attributes

callback[R]

@api private

Public Class Methods

new(callback) click to toggle source

Initialize by wrapping the given callback

@param callback [Object] the original callback that needs to be wrapped

@return [Callback] self

@since 0.1.0 @api private

# File lib/hanami/utils/callbacks.rb, line 254
def initialize(callback)
  @callback = callback
end

Public Instance Methods

call(context, *args) click to toggle source

Executes the callback within the given context and passing the given arguments.

@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 269
def call(context, *args)
  context.instance_exec(*args, &callback)
end