Class: Lotus::Utils::Callbacks::Callback
- Inherits:
-
Object
- Object
- Lotus::Utils::Callbacks::Callback
- Defined in:
- lib/lotus/utils/callbacks.rb
Overview
Proc callback It wraps an object that responds to #call
Direct Known Subclasses
Instance Attribute Summary collapse
- #callback ⇒ Object readonly
Instance Method Summary collapse
-
#call(context, *args) ⇒ void, Object
Executes the callback within the given context and passing the given arguments.
-
#initialize(callback) ⇒ Callback
constructor
Initialize by wrapping the given callback.
Constructor Details
#initialize(callback) ⇒ Callback
Initialize by wrapping the given callback
150 151 152 |
# File 'lib/lotus/utils/callbacks.rb', line 150 def initialize(callback) @callback = callback end |
Instance Attribute Details
#callback ⇒ Object (readonly)
140 141 142 |
# File 'lib/lotus/utils/callbacks.rb', line 140 def callback @callback end |
Instance Method Details
#call(context, *args) ⇒ void, Object
Executes the callback within the given context and passing the given arguments.
164 165 166 |
# File 'lib/lotus/utils/callbacks.rb', line 164 def call(context, *args) context.instance_exec(*args, &callback) end |