diff options
Diffstat (limited to 'lib/blink/events.rb')
-rw-r--r-- | lib/blink/events.rb | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/lib/blink/events.rb b/lib/blink/events.rb index 0185b3876..1dbc1b21e 100644 --- a/lib/blink/events.rb +++ b/lib/blink/events.rb @@ -6,6 +6,27 @@ require 'blink' require 'blink/type' +module Blink + # a simple class for creating callbacks + class Event + attr_reader :event, :object + attr_writer :event, :object + + def initialize(args) + unless args.include?(:event) and args.include?(:object) + raise "Event.new called incorrectly" + end + + @event = args[:event] + @object = args[:object] + end + + def trigger + @object.trigger(@event) + end + end +end + #--------------------------------------------------------------- # here i'm separating out the methods dealing with handling events @@ -44,19 +65,6 @@ class Blink::Type #--------------------------------------------------------------- #--------------------------------------------------------------- - def newevent(args) - if args[:event].nil? - raise "newevent called wrong on #{self}" - end - - return Blink::Event.new( - :event => args[:event], - :object => self - ) - end - #--------------------------------------------------------------- - - #--------------------------------------------------------------- # subscribe to an event or all events # this entire event system is a hack job and needs to # be replaced with a central event handler |