-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels.rb
31 lines (24 loc) · 805 Bytes
/
models.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
require_relative 'db'
require 'sequel/model'
RADIODNS_UK_BASE = 'https://www.radiodns.uk'
Sequel.inflections do |inflect|
inflect.irregular 'multiplex', 'multiplexes'
end
if ENV['RACK_ENV'] == 'development'
Sequel::Model.cache_associations = false
end
Sequel::Model.plugin :auto_validations
Sequel::Model.plugin :prepared_statements
Sequel::Model.plugin :subclasses unless ENV['RACK_ENV'] == 'development'
Sequel::Model.plugin :update_or_create
Dir["models/*.rb"].each {|file| require_relative file }
if ENV['RACK_ENV'] == 'development' || ENV['RACK_ENV'] == 'test'
require 'logger'
LOGGER = Logger.new($stdout)
LOGGER.level = Logger::FATAL if ENV['RACK_ENV'] == 'test'
DB.loggers << LOGGER
end
unless ENV['RACK_ENV'] == 'development'
Sequel::Model.freeze_descendents
DB.freeze
end