Class: Hanami::Utils::Callbacks::Callback Private

Inherits:
Object
  • Object
show all
Defined in:
lib/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.

Proc callback It wraps an object that responds to #call

Since:

  • 0.1.0

Direct Known Subclasses

MethodCallback

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callback) ⇒ Callback

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.

Initialize by wrapping the given callback

Since:

  • 0.1.0



232
233
234
# File 'lib/hanami/utils/callbacks.rb', line 232

def initialize(callback)
  @callback = callback
end

Instance Attribute Details

#callbackObject (readonly)

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



222
223
224
# File 'lib/hanami/utils/callbacks.rb', line 222

def callback
  @callback
end

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 passing the given arguments.

See Also:

Since:

  • 0.1.0



247
248
249
# File 'lib/hanami/utils/callbacks.rb', line 247

def call(context, *args)
  context.instance_exec(*args, &callback)
end