Class: Mediate::RequestHandler Abstract
- Inherits:
-
Object
- Object
- Mediate::RequestHandler
- Defined in:
- lib/mediate/request_handler.rb
Overview
This class is abstract.
override #handle to implement.
Abstract base class of a handler of requests. Each request type should have only one handler.
Class Method Summary collapse
-
.handles(request_class, mediator = Mediate.mediator) ⇒ void
Registers this handler for the given request Class.
Instance Method Summary collapse
-
#handle(_request) ⇒ Object
abstract
The method to implement that handles the request of the type registered for this handler.
Class Method Details
.handles(request_class, mediator = Mediate.mediator) ⇒ void
This method returns an undefined value.
Registers this handler for the given request Class.
The request Class must have Mediate::Request as a superclass.
22 23 24 |
# File 'lib/mediate/request_handler.rb', line 22 def self.handles(request_class, mediator = Mediate.mediator) mediator.register_request_handler(self, request_class) end |
Instance Method Details
#handle(_request) ⇒ Object
This method is abstract.
The method to implement that handles the request of the type registered for this handler. Whatever this method returns will be returned to the sender of the request.
36 37 38 |
# File 'lib/mediate/request_handler.rb', line 36 def handle(_request) raise NoMethodError, "handle must be implemented" end |