class Pluggaloid::Subscriber

Attributes

accepted_hash[R]

Public Class Methods

new(event, *specs, **kwrest, &callback) click to toggle source

Args

event

監視するEventのインスタンス

name:

名前(String | nil)

slug:

イベントリスナスラッグ(Symbol | nil)

tags:

Pluggaloid::HandlerTag|Array リスナのタグ

&callback

コールバック

Calls superclass method Pluggaloid::Handler::new
# File lib/pluggaloid/subscriber.rb, line 13
def initialize(event, *specs, **kwrest, &callback)
  raise Pluggaloid::UndefinedStreamIndexError, 'To call subscribe(%{event}), it must define prototype arguments include `Pluggaloid::STREAM\'.' % {event: event.name} unless event.stream_index
  super(event, **kwrest)
  @callback = callback
  @accepted_hash = @event.argument_hash(specs, nil)
  event.add_listener(self)
end

Public Instance Methods

call(*args) click to toggle source

イベントを実行する

Args

stream

イベントの引数

# File lib/pluggaloid/subscriber.rb, line 24
def call(*args)
  @callback.call(args[@event.stream_index])
end
detach() click to toggle source

このリスナを削除する

Return

self

# File lib/pluggaloid/subscriber.rb, line 31
def detach
  @event.delete_subscriber(self)
  self
end