Class: FReCon::Server

Inherits:
Sinatra::Base
  • Object
show all
Includes:
Routes
Defined in:
lib/frecon/server.rb

Overview

Public: The Sinatra web server.

Class Method Summary collapse

Methods included from Routes

attribute_routes, included, resource_routes

Class Method Details

.run!(**keyword_arguments) ⇒ Object

Internal: Set up the server and start it.

keyword_arguments - The Hash of arguments to use.

:configuration - The Configuration to use when
                 setting up the server.


66
67
68
69
70
# File 'lib/frecon/server.rb', line 66

def self.run!(**keyword_arguments)
  setup!(**keyword_arguments)

  super
end

.setup!(configuration: Configuration.construct!) ⇒ Object

Internal: Set up the server.

Sets the various Thin and Sinatra options, and sets up the database.

:configuration - The Configuration to use when starting the server.

Returns the result of setting up the database.



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/frecon/server.rb', line 47

def self.setup!(configuration: Configuration.construct!)
  # Set the Thin and Sinatra options.
  set :server, %w[thin HTTP webrick]
  set :bind, configuration["frecon"]["server"]["host"]
  set :port, configuration["frecon"]["server"]["port"]
  set :environment, configuration["frecon"]["server"]["environment"]

  # Grab out the mongoid configuration.
  mongoid = configuration["frecon"]["database"]["mongoid"]

  # Set up the database.
  Database.setup(environment, mongoid)
end

.start(**keyword_arguments) ⇒ Object

Public: Start the Server.

keyword_arguments - The Hash of arguments to use.

:configuration - The Configuration to use when
                 setting up the server.

Returns the result of starting the server.



34
35
36
# File 'lib/frecon/server.rb', line 34

def self.start(**keyword_arguments)
  run!(**keyword_arguments)
end