summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-05-29 21:17:02 +0000
committerLuke Kanies <luke@madstop.com>2005-05-29 21:17:02 +0000
commitd70229b41af53a507d6737cbf55944f798b7c2d5 (patch)
tree7362dd40be84ad0e6f8b2f16485485d76111b416
parentc0d86a4ae6c00910a44f392f0076a5785ee85791 (diff)
downloadpuppet-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
-rw-r--r--lib/blink/events.rb34
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