Class: DbCharmer::ConnectionProxy

Inherits:
ActiveSupport::BasicObject
Defined in:
lib/db_charmer/connection_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(abstract_class, db_name) ⇒ ConnectionProxy

Returns a new instance of ConnectionProxy.



10
11
12
13
# File 'lib/db_charmer/connection_proxy.rb', line 10

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



23
24
25
# File 'lib/db_charmer/connection_proxy.rb', line 23

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

Instance Attribute Details

#abstract_connection_classObject

We use this to get a connection class from the proxy



8
9
10
# File 'lib/db_charmer/connection_proxy.rb', line 8

def abstract_connection_class
  @abstract_connection_class
end

Instance Method Details

#db_charmer_connection_nameObject



15
16
17
# File 'lib/db_charmer/connection_proxy.rb', line 15

def db_charmer_connection_name
  @db_name
end

#db_charmer_connection_proxyObject



19
20
21
# File 'lib/db_charmer/connection_proxy.rb', line 19

def db_charmer_connection_proxy
  self
end