Sha256: 2e28a2b56a94d2ed88ac2fdd2e1489ae0978239cc1d9a42bccec154602f36157
Contents?: true
Size: 680 Bytes
Versions: 3
Compression:
Stored size: 680 Bytes
Contents
module StreamBot module EventHandler # register an event with the given name def event(name) register_event(name) end # register several events with the given names def events(* names) names.each do |name| event(name) end end private # the real event registration def register_event(name) class_eval do variable =:"@#{name}" define_method(name) do event = instance_variable_get(variable) if event == nil event = StreamBot::Event.new(name) instance_variable_set(variable, event) end event end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
streambot-1.0.0.rc3 | lib/streambot/event_handler.rb |
streambot-1.0.0.rc2 | lib/streambot/event_handler.rb |
streambot-1.0.0.rc1 | lib/streambot/event_handler.rb |