Class Facade
In: src/org/puremvc/ruby/patterns/facade/facade.rb
Parent: Object

In PureMVC, the Facade class assumes these responsibilities:

  • Initializing the Model, View and Controller Singletons.
  • Providing all the methods defined by the Model, View, & Controller.
  • Providing the ability to override the specific Model, View and Controller Singletons created.
  • Providing a single point of contact to the application for registering Commands and notifying Observers

Methods

Included Modules

Singleton

Attributes

controller  [RW] 
model  [RW] 
view  [RW] 

Public Class methods

This Facade implementation is a Singleton, so you can not call the constructor directly, but instead call the static Singleton Factory method Facade.instance

Public Instance methods

Check if a Command is registered for a given Notification

Check if a Mediator is registered or not

Check if a Proxy is registered

Initialize the Controller.

Called by the initialize_facade method. Override this method in your subclass of Facade if one or both of the following are true:

  • You wish to initialize a different Controller.
  • You have Commands to register with the Controller at startup.

If you don‘t want to initialize a different Controller, call super at the beginning of your method, then register Commands.

Initialize the Singleton Facade instance.

Called automatically by the constructor. Override in your subclass to do any subclass specific initializations. Be sure to call super.

Initialize the Model.

Called by the initialize_facade method. Override this method in your subclass of Facade if one or both of the following are true:

  • You wish to initialize a different Model.
  • You have Proxys to register with the Model that do not retrieve a reference to

the Facade at construction time.

If you don‘t want to initialize a different Model, call super at the beginning of your method, then register Proxys.

Note: This method is rarely overridden; in practice you are morelikely to use a Command to create and register Proxys with the Model, since Proxys with mutable data will likely need to send Notifications and thus will likely want to fetch a reference to the Facade during their construction.

Initialize the View.

Called by the initialize_facade method. Override this method in your subclass of Facade if one or both of the following are true:

  • You wish to initialize a different View.
  • You have Observers to register with the View.

If you don‘t want to initialize a different View, call super at the beginning of your method, then register Mediator instances.

Note: This method is rarely overridden; in practice you are more likely to use a Command to create and register Mediators with the View, since Mediator instances will need to send Notifications and thus will likely want to fetch a reference to the Facade during their construction.

Notify Observers.

This method is left public mostly for backward compatibility, and to allow you to send custom notification classes using the facade.

Usually you should just call send_notification and pass the parameters, never having to construct the notification yourself.

Register a Proxy with the Model by name.

Remove a previously registered Command to Notification mapping from the Controller.

Remove an Proxy from the Model by name.

Retrieve a Proxy with the Model by name.

Create and send a Notification.

Keeps us from having to construct new notification instances in our implementation code.

[Validate]