Class: Lotus::Utils::Callbacks::MethodCallback
- Defined in:
- lib/lotus/utils/callbacks.rb
Overview
Method callback It wraps a symbol or a string representing a method name that is implemented by the context within it will be called.
Instance Attribute Summary
Attributes inherited from Callback
Instance Method Summary collapse
-
#call(context, *args) ⇒ void, Object
Executes the callback within the given context and eventually passing the given arguments.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
Methods inherited from Callback
Constructor Details
This class inherits a constructor from Lotus::Utils::Callbacks::Callback
Instance Method Details
#call(context, *args) ⇒ void, Object
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.
266 267 268 269 270 271 272 273 274 |
# File 'lib/lotus/utils/callbacks.rb', line 266 def call(context, *args) method = context.method(callback) if method.parameters.any? method.call(*args) else method.call end end |
#eql?(other) ⇒ Boolean
280 281 282 |
# File 'lib/lotus/utils/callbacks.rb', line 280 def eql?(other) hash == other.hash end |
#hash ⇒ Object
276 277 278 |
# File 'lib/lotus/utils/callbacks.rb', line 276 def hash callback.hash end |