1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
13 data.each_key do |key|
38 def observe(event, &blk)
39 obs = SimpleObserver.new(event, &blk)
41 # return observer so that we can remove it later
45 def observe_limited(event, &blk)
46 obs = LimitedObserver.new(self, event, &blk)
53 notify_observers any_to_event(e)
66 def generic_call(args)
79 def initialize(event, &blk)
85 if data.has_key?(@event)
86 @blk.generic_call(data[@event])
91 class LimitedObserver < SimpleObserver
92 def initialize(observed, event, &blk)
99 @observed.delete_observer(self) if remove