Module: Herbert::Loader

Defined in:
lib/herbert/loader.rb

Overview

Bootstraps Herbert

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object

Sets up some default settings and loads all components



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/herbert/loader.rb', line 39

def self.registered(app)
  # Set some default
  # TODO to external file?
  app.set :log_requests, :db unless app.respond_to? :log_requests
  app.enable :append_log_id # If logs go to Mongo, IDs will be appended to responses
  ## register the ;debug flag patch first to enable proper logging
  app.register Herbert::Configurator::Prepatch
  app.register Herbert::Configurator::Helpers
  app.helpers Herbert::Configurator::Helpers
  # the logger
  log.level = app.debug? ? Logger::DEBUG : Logger::INFO
  # the extensions
  app.register Herbert::Configurator
  app.register Herbert::Error
  app.helpers Herbert::Error::Helpers
  app.register Sinatra::Jsonify
  app.register Sinatra::Database
  app.helpers Sinatra::Database
  app.register Sinatra::Cache
  app.helpers Sinatra::Cache
  if app.respond_to?(:validation) && app.validation then
app.register Sinatra::Validation::Extension
app.helpers Sinatra::Validation::Helpers
			end
  app.register Herbert::Ajaxify
  app.helpers Sinatra::Log
  app.register Sinatra::Log::Extension
			app.register Herbert::ResourceLoader if app.respond_to?(:resources) && app.resources
  app.helpers Herbert::Utils::Helpers
end