End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Observable#add_observer
add_observer(observer, func=:update)
lib/observer.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/observer.rb, line 153
def add_observer(observer, func=:update)
@observer_peers = {} unless defined? @observer_peers
unless observer.respond_to? func
raise NoMethodError, "observer does not respond to `#{func}'"
end
@observer_peers[observer] = func
end
Add observer as an observer on this object. So that it will receive notifications.
observer-
the object that will be notified of changes.
func-
Symbolnaming the method that will be called when thisObservablehas changes.This method must return true for
observer.respond_to?and will receive*argwhennotify_observersis called, where*argis the value passed tonotify_observersby thisObservable