Class: Mediate::NotificationHandler Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/mediate/notification_handler.rb

Overview

This class is abstract.

override #handle to implement.

Abstract base class of a handler of notifications.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.handles(notif_class = Mediate::Notification, mediator = Mediate.mediator) ⇒ void

This method returns an undefined value.

Registers this handler for the given notification Class.

The notification Class must have Mediate::Notification as a superclass.

Parameters:

  • notif_class (Class) (defaults to: Mediate::Notification)

    the Class of the notifications that get passed to this handler

  • mediator (Mediate::Mediator) (defaults to: Mediate.mediator)

    the mediator instance to register the handler with

Raises:

  • (ArgumentError)

    if notif_class does not inherit from Mediate::Notification



21
22
23
# File 'lib/mediate/notification_handler.rb', line 21

def self.handles(notif_class = Mediate::Notification, mediator = Mediate.mediator)
  mediator.register_notification_handler(self, notif_class)
end

Instance Method Details

#handle(_notification) ⇒ void

This method is abstract.

This method returns an undefined value.

The method to implement that handles the notifications registered for this handler.

Parameters:

Raises:

  • (NoMethodError)


34
35
36
# File 'lib/mediate/notification_handler.rb', line 34

def handle(_notification)
  raise NoMethodError, "handle must be implemented"
end