-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.rb
38 lines (28 loc) · 844 Bytes
/
base.rb
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
module BullsAndCows
class Base < Sinatra::Base
use Rack::Flash
register Sinatra::Partial
register Sinatra::ConfigFile
helpers Sinatra::RedirectWithFlash
config_file 'config/config.yml'
enable :sessions
set :environment, settings.environment
set :views, File.expand_path(settings.views_path)
set :public_folder, File.expand_path(settings.public_path)
set :partial_template_engine, :erb
Bundler.require settings.environment
configure :development do
DB = Sequel.sqlite settings.development[:sqlite_path]
end
register do
def user (type)
condition do
unless send "#{type}?"
flash[:info] = 'You need to be logged in to access this page.'
redirect "auth/login"
end
end
end
end
end
end