Class: FReCon::Database
Overview
Public: A system to set up the database.
Class Method Summary collapse
-
.setup(environment = FReCon.environment, mongoid = nil) ⇒ Object
Public: Set up the database.
Class Method Details
.setup(environment = FReCon.environment, mongoid = nil) ⇒ Object
Public: Set up the database.
environment - Symbol containing environment to start the database in. mongoid - Hash containing the configuration for Mongoid. If not
present, the lib/frecon/mongoid.yml file is given to
Mongoid.load!. If present, the Hash is dumped to a
tempfile which is given to Mongoid.load!.
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 30 def self.setup(environment = FReCon.environment, mongoid = nil) if mongoid.is_a?(Hash) mongoid_tempfile = Tempfile.new("FReCon") mongoid_tempfile.write(mongoid.to_h.to_yaml) mongoid_tempfile.rewind Mongoid.load!(mongoid_tempfile.path, environment) else Mongoid.load!(File.join(File.dirname(__FILE__), "mongoid.yml"), environment) end if environment == :development Mongoid.logger.level = Logger::DEBUG Mongoid.logger = Logger.new($stdout) Moped.logger.level = Logger::DEBUG Moped.logger = Logger.new($stdout) end end |