Sha256: 79d86d3ea83dc99a579eb43fefef0f39951167063ca55696d9a3f50b9898a888
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
require 'mongo' module Ganymed # @private class MongoDB attr_reader :config def initialize(config) @config = config log.info("using MongoDB at #{config.host}:#{config.port}/#{config.database}") end def connection @connection ||= ::Mongo::Connection.new(config.host, config.port, :pool_size => 5, :pool_timeout => 5) end def db @db ||= connection.db(config.database) end def collection(ns) db[ns].tap do |col| col.ensure_index([['c', ::Mongo::ASCENDING]]) col.ensure_index([['o', ::Mongo::ASCENDING]]) col.ensure_index([['t', ::Mongo::ASCENDING]]) col.ensure_index([['c', ::Mongo::ASCENDING], ['o', ::Mongo::ASCENDING]]) col.ensure_index([['o', ::Mongo::ASCENDING], ['t', ::Mongo::ASCENDING]]) col.ensure_index([['c', ::Mongo::ASCENDING], ['o', ::Mongo::ASCENDING], ['t', ::Mongo::ASCENDING]], :unique => true) end end def method_missing(method, *args, &block) db.__send__(method, *args, &block) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ganymed-0.1.2 | lib/ganymed/mongodb.rb |
ganymed-0.1.1 | lib/ganymed/mongodb.rb |
ganymed-0.1.0 | lib/ganymed/mongodb.rb |