module Trialday

Trialday Base

The Base class contains the integrations between the Application class and the router. It uses class methods to, when called, invoke the Router.route. This will add the new route to the list of available routes.

see Sinatra: lib/sinatra/base.rb#L1599

Trialday Delegator

The Delegator dynamic creates the integrations between the public api and the Trialday::Application class. It generates get/post methods on the fly and by metaprogramming defines what should happen whe the API is called. The Application is then registered to accept the parameters, calling passing the routes path and body block to the scope.

see Sinatra: lib/sinatra/base.rb#L1908

Trialday Application

Rack Applications needs an object which will have a 'call' method. This call method can be simple and just return a HTTP response. In our scenario this class will get the reference from Rack::Request and call the 'serve_request' method.

The serve_request method returns the Trialday::Router. the ida is to have an main object to orchestrate the possible calls to the framework API.

To start up the Rack server we use ruby's at_exist method. This will ensure that the Router object will be completely ready for Rack to server, in this case, using WEBrick.

see Sinatra: /lib/sinatra/main.rb#L26