Class: Suggester::Server
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Suggester::Server
- Defined in:
- lib/suggester/server.rb
Overview
Core server class
Class Method Summary collapse
-
.add_handler(name, handler) ⇒ Object
Register a handler instance to its handler name.
-
.handler(name) ⇒ Object
Returns the handler instance given the handler name.
-
.handlers ⇒ Object
Returns the hash of all handler names to their instances.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Server
constructor
Create an instance of the server.
Constructor Details
#initialize(*args) ⇒ Server
Create an instance of the server. At this time, we spawn a separate thread that will reload handlers as needed to prevent locking the server thread.
22 23 24 25 |
# File 'lib/suggester/server.rb', line 22 def initialize(*args) super(*args) spawn_refresh_thread! end |
Class Method Details
.add_handler(name, handler) ⇒ Object
Register a handler instance to its handler name
120 121 122 123 |
# File 'lib/suggester/server.rb', line 120 def self.add_handler(name, handler) @handlers ||= {} @handlers[name] = handler end |
.handler(name) ⇒ Object
Returns the handler instance given the handler name
114 115 116 117 |
# File 'lib/suggester/server.rb', line 114 def self.handler(name) @handlers ||= {} @handlers[name] end |
.handlers ⇒ Object
Returns the hash of all handler names to their instances
109 110 111 |
# File 'lib/suggester/server.rb', line 109 def self.handlers @handlers end |