Observable

module Observable

The Observer pattern (also known as publish/subscribe) provides a simple mechanism for one object to inform a set of interested third-party objects when its state changes.

Mechanism

The notifying class mixes in the Observable module, which provides the methods for managing the associated observer objects.

The observable object must:

  • assert that it has #changed

  • call #notify_observers

An observer subscribes to updates using #add_observer, which also specifies the method called via notify_observers. The default method for notify_ob