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
110 111 112 113 |
# File 'lib/suggester/server.rb', line 110 def self.add_handler(name, handler) @handlers ||= {} @handlers[name] = handler end |
.handler(name) ⇒ Object
Returns the handler instance given the handler name
104 105 106 107 |
# File 'lib/suggester/server.rb', line 104 def self.handler(name) @handlers ||= {} @handlers[name] end |
.handlers ⇒ Object
Returns the hash of all handler names to their instances
99 100 101 |
# File 'lib/suggester/server.rb', line 99 def self.handlers @handlers end |