Module: Mediate

Defined in:
lib/mediate.rb,
lib/mediate/request.rb,
lib/mediate/version.rb,
lib/mediate/mediator.rb,
lib/mediate/notification.rb,
lib/mediate/error_handler.rb,
lib/mediate/request_handler.rb,
lib/mediate/error_handler_state.rb,
lib/mediate/prerequest_behavior.rb,
lib/mediate/notification_handler.rb,
lib/mediate/postrequest_behavior.rb,
lib/mediate/errors/no_handler_error.rb,
lib/mediate/errors/request_handler_already_exists_error.rb

Overview

Namespace containing a simple implementation of the mediator pattern.

Defined Under Namespace

Modules: Errors Classes: ErrorHandler, ErrorHandlerState, Mediator, Notification, NotificationHandler, PostrequestBehavior, PrerequestBehavior, Request, RequestHandler

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.dispatch(request) ⇒ Object

Sends a request to the registered handler, passing to any applicable pipeline behaviors.

Parameters:

Returns:

  • the response returned from the Mediate::RequestHandler

Raises:



31
32
33
# File 'lib/mediate.rb', line 31

def self.dispatch(request)
  mediator.dispatch(request)
end

.mediatorMediate::Mediator

Get the current mediator instance. This will be a singleton throughout the lifetime of the program.

Returns:



17
18
19
# File 'lib/mediate.rb', line 17

def self.mediator
  Mediator.instance
end

.publish(notification) ⇒ void

This method returns an undefined value.

Sends a notification to all registered handlers for the given notification’s type.

Parameters:



42
43
44
# File 'lib/mediate.rb', line 42

def self.publish(notification)
  mediator.publish(notification)
end