Module: Boxlet::Db
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
Instance Method Summary collapse
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
9 10 11 |
# File 'lib/boxlet/db.rb', line 9 def db @db end |
Instance Method Details
#connect ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/boxlet/db.rb', line 15 def connect config = Boxlet.config db_config = config[:db][config[:environment].to_sym || :development] host = db_config[:host] || 'localhost' port = db_config[:port] || MongoClient::DEFAULT_PORT Boxlet.log(:info, "INFO: Connecting to #{host}:#{port}") client = MongoClient.new(host, port) db = client.db(db_config[:db] || 'boxlet_development') return db end |
#connection ⇒ Object
11 12 13 |
# File 'lib/boxlet/db.rb', line 11 def connection @db ||= self.connect end |