-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.ru
42 lines (34 loc) · 1001 Bytes
/
config.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
real_file = Kernel.const_get('File')
$: << real_file.dirname(__FILE__)
begin
# Try to require the preresolved locked set of gems.
require real_file.expand_path('../.bundle/environment', __FILE__)
rescue LoadError
# Fall back on doing an unlocked resolve at runtime.
require "rubygems"
require "bundler"
Bundler.setup
end
Bundler.require(:default)
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db('hStore')
end
require 'lib/namespace_context'
# Set up the models
Dir[real_file.dirname(__FILE__) + '/lib/models/*.rb'].each {|file| require file }
# Load the web request handlers, order is significant
require 'lib/controllers/document'
require 'lib/controllers/root'
require 'lib/controllers/section'
map '/' do
[HStore::Document, HStore::Root, HStore::SectionController].each_with_index do |clazz, i|
clazz.configure do |c|
c.set :root, real_file.dirname(__FILE__)
end
if i < 2
use clazz
else
run clazz
end
end
end