Class: Connectator::DBIProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/connectator/dbi_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ DBIProxy

Returns a new instance of DBIProxy.



4
5
6
# File 'lib/connectator/dbi_proxy.rb', line 4

def initialize(connection)
  @connection = connection
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &blk) ⇒ Object



27
28
29
# File 'lib/connectator/dbi_proxy.rb', line 27

def method_missing(method, *args, &blk)
  connection.send(method, *args, &blk)
end

Instance Method Details

#closeObject



12
13
14
# File 'lib/connectator/dbi_proxy.rb', line 12

def close
  connection.disconnect
end

#connectionObject



8
9
10
# File 'lib/connectator/dbi_proxy.rb', line 8

def connection
  @connection
end

#select_all_to_hash(query) ⇒ Object

Do not use this method on queries that return lots of data because it would use a lot of memory.



18
19
20
21
22
23
24
25
# File 'lib/connectator/dbi_proxy.rb', line 18

def select_all_to_hash(query)
  result = []
  sth = connection.execute(query)
  sth.fetch_hash do |row|
    result << row
  end
  result
end