Sha256: 15e65e8d334111ce90e6905301edc1ebe9adef9b11281187d156affe8f0fa82f

Contents?: true

Size: 706 Bytes

Versions: 5

Compression:

Stored size: 706 Bytes

Contents

# Simple proxy that sends all method calls to a real database connection
module DbCharmer
  class ConnectionProxy < ActiveSupport::BasicObject
    # We need to do this because in Rails 2.3 BasicObject does not remove object_id method, which is stupid
    undef_method(:object_id) if instance_methods.member?('object_id')

    def initialize(abstract_class, db_name)
      @abstract_connection_class = abstract_class
      @db_name = db_name
    end

    def db_charmer_connection_name
      @db_name
    end

    def db_charmer_connection_proxy
      self
    end

    def method_missing(meth, *args, &block)
      @abstract_connection_class.retrieve_connection.send(meth, *args, &block)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
db-charmer-1.7.0.pre6 lib/db_charmer/connection_proxy.rb
db-charmer-1.7.0.pre5 lib/db_charmer/connection_proxy.rb
db-charmer-1.7.0.pre4 lib/db_charmer/connection_proxy.rb
db-charmer-1.7.0.pre3 lib/db_charmer/connection_proxy.rb
db-charmer-1.7.0.pre2 lib/db_charmer/connection_proxy.rb