Class: Jax::Server

Inherits:
Rails::Server
  • Object
show all
Defined in:
lib/jax/server.rb

Overview

The server is just a bare-bones Rails application built into the Jax gem. It mounts Jax::Engine at the root path.

The server can be run from any Jax application by simply executing the ‘jax server` command.

Note: in a Rails app, you should simply mount Jax::Engine directly in your ‘config/routes.rb` file:

Rails.application.routes.draw do
  mount Jax::Engine => "/jax" if Rails.env != "production"
end

The above example will mount the Jax development suite in development and test modes, but not in production mode. Usually, you won’t want to expose Jax::Engine to a production environment, but of course this is up to you.

Note that you only need to mount Jax::Engine if you want to use the development suite. You get the Jax assets (e.g. the Jax JavaScript API) for free when you add Jax to your Gemfile.

Executing ‘jax server` in a Rails application is equivalent to executing `rails server`.

Defined Under Namespace

Classes: Options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Server

Returns a new instance of Server.



70
71
72
73
# File 'lib/jax/server.rb', line 70

def initialize(*args)
  @args = args
  super()
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



64
65
66
# File 'lib/jax/server.rb', line 64

def args
  @args
end

Instance Method Details

#middlewareObject



75
76
77
78
79
80
81
# File 'lib/jax/server.rb', line 75

def middleware
  middlewares = []
  middlewares << [::Rails::Rack::LogTailer, log_path] unless options[:daemonize] || options[:quiet]
  middlewares << [::Rails::Rack::Debugger]  if options[:debugger]
  middlewares << [::Rack::ContentLength]
  Hash.new(middlewares)
end

#opt_parserObject



66
67
68
# File 'lib/jax/server.rb', line 66

def opt_parser
  Options.new
end

#optionsObject



83
84
85
# File 'lib/jax/server.rb', line 83

def options
  @options ||= parse_options(args)
end