lib/openwfe/util/observable.rb in openwferu-0.9.15 vs lib/openwfe/util/observable.rb in openwferu-0.9.16
- old
+ new
@@ -55,10 +55,11 @@
#
# Returns the observer object (or the block's Proc object), could
# be useful when removing the observer.
#
def add_observer (channel, observer=nil, &callback)
+
observer = callback unless observer
(@observers[channel] ||= []) << observer
observer
end
@@ -103,10 +104,12 @@
observers.delete(observer) if observers
end
def do_notify (target_channel, channel, *args)
+ #ldebug { "do_notify() @observers.size is #{@observers.size}" }
+
if target_channel.is_a?(String)
observers = []
@observers.each do |c, o|
@@ -130,10 +133,10 @@
observers.each do |obs|
obs.call channel, *args
end
- observers.size > 0
+ (observers.size > 0)
#
# returns true if at least one observer was called
end
end
end