A Model represents an application data structure which can have observers.
The observers are typically subclasses of View, but need not be. Class Model
provides mechanisms for attaching and removing observers, and for notifying
observers when the Model changes.
- views
- List of objects which are observing this Model. Do not modify this list directly; use the add_view and remove_view methods to add and remove observers.
- add_view(view)
- Adds the given object as an observer of this Model. If the object defines an add_model method, it is called with this Model as argument.
- remove_view(view)
- Removes the given object as an observer of this Model. If the object defines a remove_model method, it is called with this Model as argument.
- notify_views(message = 'model_changed', ...)
- Calls a method of each observer with the same name as the message, passing it any additional arguments.
- destroy
- Dissociates the Model from any attached observers, and calls the model_destroyed method of each observer which defines it.