Class: Rambo::Env
- Inherits:
-
Object
- Object
- Rambo::Env
- Defined in:
- lib/rambo/env.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Env
constructor
A new instance of Env.
Constructor Details
#initialize ⇒ Env
Returns a new instance of Env.
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 |
# File 'lib/rambo/env.rb', line 11 def initialize begin # TODO: config reload if dbconf = Env.config['mongodb'] require 'mongomapper' @@database ||= MongoMapper.database = dbconf['database'] end if dbconf = Env.config['datamapper'] require 'dm-core' require 'dm-validations' require 'dm-timestamps' @@connection ||= DataMapper.setup( :default, :adapter => :mysql, :host => dbconf['host'], :database => dbconf['database'], :username => dbconf['username'], :password => dbconf['password'] ) @@dblogger ||= DataObjects::Mysql.logger = DataObjects::Logger.new(STDOUT, dbconf['logging']) if dbconf['logging'] end rescue Exception => e puts "Exception initializing environment: #{e.}" puts e.backtrace.join("\n") raise e end end |
Class Method Details
.config ⇒ Object
6 7 8 9 |
# File 'lib/rambo/env.rb', line 6 def self.config @@config ||= YAML.load_file("rambo.yml") rescue nil @@config ||= {} end |