diff options
author | Luke Kanies <luke@madstop.com> | 2005-05-29 21:17:02 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-05-29 21:17:02 +0000 |
commit | d70229b41af53a507d6737cbf55944f798b7c2d5 (patch) | |
tree | 7362dd40be84ad0e6f8b2f16485485d76111b416 /lib | |
parent | c0d86a4ae6c00910a44f392f0076a5785ee85791 (diff) | |
download | puppet-d70229b41af53a507d6737cbf55944f798b7c2d5.tar.gz puppet-d70229b41af53a507d6737cbf55944f798b7c2d5.tar.xz puppet-d70229b41af53a507d6737cbf55944f798b7c2d5.zip |
update before rename
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@278 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-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 |