Class: Pluggaloid::Listener
- Defined in:
- lib/pluggaloid/listener.rb
Constant Summary
Constants inherited from Handler
Instance Attribute Summary
Attributes inherited from Handler
Attributes inherited from Identity
Class Method Summary collapse
-
.cancel! ⇒ Object
プラグインコールバックをこれ以上実行しない。.
Instance Method Summary collapse
-
#call(*args) ⇒ Object
イベントを実行する ==== Args [*args] イベントの引数.
-
#detach ⇒ Object
このリスナを削除する ==== Return self.
-
#initialize(event, **kwrest, &callback) ⇒ Listener
constructor
Args [event] 監視するEventのインスタンス [name:] 名前(String | nil) [slug:] イベントリスナスラッグ(Symbol | nil) [tags:] Pluggaloid::HandlerTag|Array リスナのタグ [&callback] コールバック.
Methods inherited from Handler
#add_tag, #inspect, #remove_tag
Methods inherited from Identity
Constructor Details
#initialize(event, **kwrest, &callback) ⇒ Listener
Args
- event
-
監視するEventのインスタンス
- name:
-
名前(String | nil)
- slug:
-
イベントリスナスラッグ(Symbol | nil)
- tags:
-
Pluggaloid::HandlerTag|Array リスナのタグ
- &callback
-
コールバック
16 17 18 19 |
# File 'lib/pluggaloid/listener.rb', line 16 def initialize(event, **kwrest, &callback) super @callback = callback event.add_listener(self) end |
Class Method Details
.cancel! ⇒ Object
プラグインコールバックをこれ以上実行しない。
7 8 |
# File 'lib/pluggaloid/listener.rb', line 7 def self.cancel! throw :plugin_exit, false end |
Instance Method Details
#call(*args) ⇒ Object
イベントを実行する
Args
- *args
-
イベントの引数
24 25 |
# File 'lib/pluggaloid/listener.rb', line 24 def call(*args) @callback.call(*args, &self.class.method(:cancel!)) end |
#detach ⇒ Object
このリスナを削除する
Return
self
30 31 32 |
# File 'lib/pluggaloid/listener.rb', line 30 def detach @event.delete_listener(self) self end |