Sha256: 25892cfefd237e93e0a53afc1360de6cf359a20e82a78efab6faca45c52f662b
Contents?: true
Size: 914 Bytes
Versions: 1
Compression:
Stored size: 914 Bytes
Contents
require 'mongoid/database_proxy' # # Proxy that enables runtime swapping of the MongoDB connection. This is # not an ideal-solution, performance-wise, as a quick check shows that # method invocation via method_missing is about three times as slow as # direct invocation on the object. # # What this does allow us to do, however, is very transparently swap out # Mongo::Connection instances underneath Mongoid, without having to # rewrite large portions of the codebase. In theory, this should result # in a relatively painless connection-swapping system. # class ConnectionProxy def ConnectionProxy.from_uri(*args) new(*args) end def initialize(*args) @connection = Mongo::Connection.from_uri(*args) end def db(name) @database ||= DatabaseProxy.new(@connection, name) end def method_missing(*args, &block) @connection.send(*args, &block) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-multi-db-3.0.0 | lib/mongoid/connection_proxy.rb |