class Concurrent::IVar
def add_observer(observer = nil, func = :update, &block)
-
func
(Symbol
) -- symbol naming the method to call when this `Observable` has changes` -
observer
(Object
) -- the object that will be notified of changes
def add_observer(observer = nil, func = :update, &block) raise ArgumentError.new('cannot provide both an observer and a block') if observer && block direct_notification = false if block observer = block func = :call end mutex.synchronize do if event.set? direct_notification = true else observers.add_observer(observer, func) end end observer.send(func, Time.now, self.value, reason) if direct_notification observer end