Class: PureMVC::Mediator

Inherits:
Notifier show all
Defined in:
src/patterns/mediator/mediator.rb

Overview

A base IMediator implementation.

See Also:

Constant Summary collapse

NAME =

The name of the Mediator.

Typically, a Mediator will be written to serve one specific control or group controls and so, will not have a need to be dynamically named.

'Mediator'

Constants inherited from Notifier

Notifier::MULTITON_MSG

Instance Attribute Summary collapse

Attributes inherited from Notifier

#multiton_key

Instance Method Summary collapse

Methods inherited from Notifier

#facade, #initialize_notifier, #send_notification

Constructor Details

#initialize(name = nil, component = nil) ⇒ Mediator

Initializes a new Mediator instance.

Parameters:

  • name (String | nil) (defaults to: nil)

    the name of the mediator

  • component (Object, nil) (defaults to: nil)

    the component this mediator manages



32
33
34
35
36
# File 'src/patterns/mediator/mediator.rb', line 32

def initialize(name = nil, component = nil)
  super()
  @name = name || NAME
  @component = component
end

Instance Attribute Details

#componentObject?

Returns The component associated with this Mediator.

Returns:

  • (Object, nil)

    The component associated with this Mediator.



26
27
28
# File 'src/patterns/mediator/mediator.rb', line 26

def component
  @component
end

#nameString (readonly)

Returns The name of the Mediator.

Returns:

  • (String)

    The name of the Mediator.



23
24
25
# File 'src/patterns/mediator/mediator.rb', line 23

def name
  @name
end

Instance Method Details

#handle_notification(notification) ⇒ Object

Handles a notification.

Parameters:

  • notification (_INotification)

    the notification to handle



48
# File 'src/patterns/mediator/mediator.rb', line 48

def handle_notification(notification); end

#list_notification_interestsArray<String>

Returns an array of notification names this mediator is interested in.

Returns:

  • (Array<String>)

    list of notification names



41
42
43
# File 'src/patterns/mediator/mediator.rb', line 41

def list_notification_interests
  []
end

#on_registerObject

Called when the mediator is registered.



51
# File 'src/patterns/mediator/mediator.rb', line 51

def on_register; end

#on_removeObject

Called when the mediator is removed.



54
# File 'src/patterns/mediator/mediator.rb', line 54

def on_remove; end