aboutsummaryrefslogtreecommitdiffstats
path: root/lib/plum/event_emitter.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-10-25 23:44:05 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-10-25 23:44:05 +0900
commitbaf217cf0ed4eb5990d7823903a152d0c337c377 (patch)
tree2ddf447357d9b106ca7e0a9a3f9e9c2c97e6c599 /lib/plum/event_emitter.rb
parente14480d588bfc6182fab7b9ed7292c317b36a752 (diff)
downloadplum-baf217cf0ed4eb5990d7823903a152d0c337c377.tar.gz
improve docs
Diffstat (limited to 'lib/plum/event_emitter.rb')
-rw-r--r--lib/plum/event_emitter.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/plum/event_emitter.rb b/lib/plum/event_emitter.rb
index 90484fc..572900e 100644
--- a/lib/plum/event_emitter.rb
+++ b/lib/plum/event_emitter.rb
@@ -1,12 +1,14 @@
module Plum
module EventEmitter
# Registers an event handler to specified event. An event can have multiple handlers.
- # @param name [String] The name of event.
+ # @param name [Symbol] The name of event.
# @yield Gives event-specific parameters.
def on(name, &blk)
(callbacks[name] ||= []) << blk
end
+ # Invokes an event and call handlers with args.
+ # @param name [Symbol] The identifier of event.
def callback(name, *args)
(cbs = callbacks[name]) && cbs.each {|cb| cb.call(*args) }
end