lib/streambot/event_handler.rb in streambot-1.0.0.rc3 vs lib/streambot/event_handler.rb in streambot-1.0.0.rc4
- old
+ new
@@ -10,23 +10,27 @@
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
+ define_event_method(name);
+ end
+ end
+
+ def define_event_method(name)
+ 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
\ No newline at end of file