module Genesis::Server::ClassMethods

Methods to be injected onto the class

Public Instance Methods

start(port, routes, **kwargs) { || ... } click to toggle source
# File lib/genesis/server.rb, line 14
def start(port, routes, **kwargs, &block)
  @port = port
  @handle_routes = routes || []
  @channel = kwargs[:channel]
  @args = kwargs

  # Allow a custom, non EM, server to be run
  if block_given? && block
    yield
  else
    default_start
  end
end

Private Instance Methods

default_start() click to toggle source
# File lib/genesis/server.rb, line 30
def default_start
  # But default to an EM server if nothing else is provided
  EM.start_server '0.0.0.0', @port, self do |conn|
    conn.channel = @channel
    conn.handle_routes = @handle_routes
  end
end