Class: Lita::Callback Private
- Inherits:
-
Object
- Object
- Lita::Callback
- Defined in:
- lib/lita/callback.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.
Represents the action that is taken when a route or event is triggered. It can be a block or the name of a method on object.
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
private
A block that should be used as the callback.
-
#method_name ⇒ Object
readonly
private
The name of the method in the plugin that should be called as the callback.
Instance Method Summary collapse
-
#call(host, *args) ⇒ Object
private
Invokes the callback.
-
#initialize(method_name_or_callable) ⇒ Callback
constructor
private
A new instance of Callback.
Constructor Details
#initialize(method_name) ⇒ Callback #initialize(callable) ⇒ 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.
Returns a new instance of Callback.
18 19 20 21 22 23 24 |
# File 'lib/lita/callback.rb', line 18 def initialize(method_name_or_callable) if method_name_or_callable.respond_to?(:call) @block = method_name_or_callable else @method_name = method_name_or_callable end end |
Instance Attribute Details
#block ⇒ Object (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.
A block that should be used as the callback.
8 9 10 |
# File 'lib/lita/callback.rb', line 8 def block @block end |
#method_name ⇒ Object (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.
The name of the method in the plugin that should be called as the callback.
11 12 13 |
# File 'lib/lita/callback.rb', line 11 def method_name @method_name end |
Instance Method Details
#call(host, *args) ⇒ 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.
Invokes the callback.
27 28 29 30 31 32 33 34 35 |
# File 'lib/lita/callback.rb', line 27 def call(host, *args) if block host.instance_exec(*args, &block) else host.public_send(method_name, *args) end true end |