Class: Dispatcher::CoreDispatcher
- Inherits:
-
Object
- Object
- Dispatcher::CoreDispatcher
- Defined in:
- lib/dispatcher.rb
Overview
A core Dispatcher interface.
This is intended as a ‘virtual’ class that all other dispatcher interfaces inherit from.
Direct Known Subclasses
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
Set the default_dispatcher to the last class that inherits CoreDispatcher.
Instance Method Summary collapse
-
#handle(request) ⇒ Object
Super-simple handler.
-
#initialize(responder, *config) ⇒ CoreDispatcher
constructor
Creates a new.
-
#listen ⇒ Object
Start listening for incoming requests.
Constructor Details
#initialize(responder, *config) ⇒ CoreDispatcher
Creates a new
56 57 58 59 |
# File 'lib/dispatcher.rb', line 56 def initialize(responder, *config) @responder = responder @config = config end |
Class Method Details
.inherited(subclass) ⇒ Object
Set the default_dispatcher to the last class that inherits CoreDispatcher.
79 80 81 |
# File 'lib/dispatcher.rb', line 79 def self.inherited(subclass) Dispatcher.default_dispatcher = subclass end |
Instance Method Details
#handle(request) ⇒ Object
Super-simple handler.
Just outputs any STDOUT content. Buffering should be done at the Responder level.
73 74 75 76 |
# File 'lib/dispatcher.rb', line 73 def handle(request) response = Response.new(@responder) response.render(request) end |
#listen ⇒ Object
Start listening for incoming requests.
62 63 64 65 66 67 68 |
# File 'lib/dispatcher.rb', line 62 def listen err = 'You are attempting to use the default Dispatcher interface. ' err += 'Most likely the library was unable to autodetect an appropriate interface. ' err += 'Try specifying one manually via a require \'request/<interface>\'.' raise TypeError, err, caller end |