Skip to content

End of Life Ruby 3.2 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)

Add observer as an observer on this object. So that it will receive notifications.

observer

the object that will be notified of changes.

func

Symbol naming the method that will be called when this Observable has changes.

This method must return true for observer.respond_to? and will receive *arg when notify_observers is called, where *arg is the value passed to notify_observers by this Observable

See also #changed #changed? also in 3.3 · 3.1 · 3.0