Module: Aerogel::Config

Defined in:
lib/aerogel/core/config.rb

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object

Configures application.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/aerogel/core/config.rb', line 17

def self.registered(app)
  app.set :root, Aerogel.application_path
  app.set :views, Aerogel.get_resource_paths( :views ).reverse
  app.set :erb, trim: '-', layout: "layouts/application.html".to_sym

  reset!(app)
  # Load configs
  Aerogel.get_resource_list( :config, '*.conf', app.environment ).each do |config_filename|
    Aerogel.config.load config_filename
  end
  # register reloader
  setup_reloader(app) if Aerogel.config.aerogel.reloader?

  # set :protection, true
  # set :protect_from_csrf, true
  app.enable :sessions
  if Aerogel.config.aerogel.sessions.domain?
    app.set :sessions, domain: Aerogel.config.aerogel.sessions.domain!
  end
  # TODO: demand to configure session secret on application level
  if Aerogel.config.aerogel.sessions.secret?
    app.set :session_secret, Aerogel.config.aerogel.sessions.secret!
  end

  app.use Rack::Protection::AuthenticityToken
  app.use Rack::Flash, :sweep => true
  app.helpers Sinatra::RedirectWithFlash

  app.register Sinatra::MultiRoute
end