Module

Observable

Inheritance

Implements the Observable design pattern as a mixin so that other objects can be notified of changes in state. See observer.rb for details and an example.

Methods

Instance

Visibility Signature
public add_observer (observer)
public changed (state=true)
public changed? ()
public count_observers ()
public delete_observer (observer)
public delete_observers ()
public notify_observers (*arg)

Instance Method Detail

add_observer(observer)

Add observer as an observer on this object. observer will now receive notifications.

changed(state=true)

Set the changed state of this object. Notifications will be sent only if the changed state is true.

changed?()

Query the changed state of this object.

count_observers()

Return the number of observers associated with this object.

delete_observer(observer)

Delete observer as an observer on this object. It will no longer receive notifications.

delete_observers()

Delete all observers associated with this object.

notify_observers(*arg)

If this object‘s changed state is true, invoke the update method in each currently associated observer in turn, passing it the given arguments. The changed state is then set to false.