Sha256: 3b0f3985eeb30ba299c59d3463b1c3e92076adf5a42d93467da14558ff0172f8

Contents?: true

Size: 811 Bytes

Versions: 16

Compression:

Stored size: 811 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')

    # We use this to get a connection class from the proxy
    attr_accessor :abstract_connection_class

    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

16 entries across 16 versions & 2 rubygems

Version Path
db-charmer-1.8.4 lib/db_charmer/connection_proxy.rb
db-charmer-1.8.3 lib/db_charmer/connection_proxy.rb
db-charmer-1.8.2 lib/db_charmer/connection_proxy.rb
db-charmer-1.8.1 lib/db_charmer/connection_proxy.rb
db-charmer-1.8.0 lib/db_charmer/connection_proxy.rb
db-charmer-1.8.0.pre1 lib/db_charmer/connection_proxy.rb
yam-db-charmer-1.7.4.14 lib/db_charmer/connection_proxy.rb
yam-db-charmer-1.7.4.13 lib/db_charmer/connection_proxy.rb
yam-db-charmer-1.7.4.10 lib/db_charmer/connection_proxy.rb
yam-db-charmer-1.7.4.9 lib/db_charmer/connection_proxy.rb
yam-db-charmer-1.7.4.8 lib/db_charmer/connection_proxy.rb
yam-db-charmer-1.7.4.0 lib/db_charmer/connection_proxy.rb
yam-db-charmer-1.7.01 lib/db_charmer/connection_proxy.rb
db-charmer-1.7.1 lib/db_charmer/connection_proxy.rb
db-charmer-1.7.0 lib/db_charmer/connection_proxy.rb
db-charmer-1.7.0.pre7 lib/db_charmer/connection_proxy.rb