Class: Jobim::Server
- Inherits:
-
Object
- Object
- Jobim::Server
- Defined in:
- lib/jobim/server.rb
Overview
HTTP Server container. Contains the Rack application definition and routing tables. Class explicitly leverages ‘::Thin::Server` to create the HTTP server, this should possibly be changed.
Instance Attribute Summary collapse
-
#app ⇒ Rack::Builder
Memoized accessor for the server Rack application.
-
#server ⇒ Thin::Server
Memoized accessor for the internal server instance.
-
#settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
-
.start!(opts) ⇒ Jobim::Server
Utitly wrapper to create and start a new ‘Jobim::Server` instnace.
Instance Method Summary collapse
-
#initialize(settings) {|_self| ... } ⇒ Server
constructor
A new instance of Server.
-
#start ⇒ Object
Pass through delegation to the internal server object’s start method.
Constructor Details
#initialize(settings) {|_self| ... } ⇒ Server
Returns a new instance of Server.
19 20 21 22 23 |
# File 'lib/jobim/server.rb', line 19 def initialize(settings, &block) @settings = settings yield self if block_given? end |
Instance Attribute Details
#app ⇒ Rack::Builder
Memoized accessor for the server Rack application.
NB. This has been split into a memoized called to ‘#build_app` becuase of the way the `Rack::Builder` class handles scope in the context of `instance_eval` instead of `yield`.
32 33 34 |
# File 'lib/jobim/server.rb', line 32 def app @app end |
#server ⇒ Thin::Server
Memoized accessor for the internal server instance.
This is currently explicitly a ‘::Thin::Server`, possibly should change into a more generic form.
42 43 44 |
# File 'lib/jobim/server.rb', line 42 def server @server end |
#settings ⇒ Object
Returns the value of attribute settings.
17 18 19 |
# File 'lib/jobim/server.rb', line 17 def settings @settings end |
Class Method Details
.start!(opts) ⇒ Jobim::Server
Utitly wrapper to create and start a new ‘Jobim::Server` instnace.
13 14 15 |
# File 'lib/jobim/server.rb', line 13 def self.start!(opts) Jobim::Server.new(opts).start end |
Instance Method Details
#start ⇒ Object
Pass through delegation to the internal server object’s start method. Handles daemonizing the server before starting it if nessesary.
60 61 62 63 64 65 66 67 |
# File 'lib/jobim/server.rb', line 60 def start Thin::Logging.silent = settings.quiet puts ">>> Serving #{settings.dir}" server.daemonize if settings.daemonize server.start end |