Module: Jp::Server::MongoConnection
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Instance Method Summary collapse
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
4 5 6 |
# File 'lib/rb/jp/server/mongo_connection.rb', line 4 def database @database end |
Instance Method Details
#connect_to_mongo(options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rb/jp/server/mongo_connection.rb', line 5 def connect_to_mongo defaults = { :mongo_uri => 'mongodb://localhost', :mongo_pool_size => 10, :mongo_pool_timeout => 60, } = defaults.merge() unless [:mongo_db] raise ArgumentError.new "mongo_db option must be specified" end # Connect to mongodb if .member? :injected_mongo_database then @database = [:injected_mongo_database] else connection = Mongo::Connection.from_uri( [:mongo_uri], :pool_size => [:mongo_pool_size], :timeout => [:mongo_pool_timeout], ) @database = connection.db([:mongo_db]) end end |