Class: FReCon::Database

Inherits:
Object show all
Defined in:
lib/frecon/database.rb

Overview

Public: A system to set up the database.

Class Method Summary collapse

Class Method Details

.setup!Object

Public: Set up the database.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/frecon/database.rb', line 25

def self.setup!
	Mongoid.load!(File.join(File.dirname(__FILE__), 'mongoid.yml'), FReCon::ENVIRONMENT.variable)

	level = case (configured_level = FReCon::ENVIRONMENT.console['level'])
	        when /^d/i
		        ::Logger::DEBUG
	        when /^e/i
		        ::Logger::ERROR
	        when /^f/i
		        ::Logger::FATAL
	        when /^i/i
		        ::Logger::INFO
	        when /^u/i
		        ::Logger::UNKNOWN
	        when /^w/i
		        ::Logger::WARN
	        else
		        ::Logger::WARN
	        end

	if !!configured_level
		Mongoid.logger = Logger.new($stdout)
		Mongoid.logger.level = level
	end
end