Class: DB::ActiveRecord::Adapter::Postgres

Inherits:
ActiveRecord::ConnectionAdapters::AbstractAdapter
  • Object
show all
Defined in:
lib/db/active_record/adapter/postgres.rb

Instance Method Summary collapse

Constructor Details

#initialize(adapter, config) ⇒ Postgres

Returns a new instance of Postgres.



16
17
18
19
20
# File 'lib/db/active_record/adapter/postgres.rb', line 16

def initialize(adapter, config)
	super(config)
	
	@adapter = adapter
end

Instance Method Details

#connectObject



22
23
24
# File 'lib/db/active_record/adapter/postgres.rb', line 22

def connect
	@raw_connection ||= @adapter.call
end

#raw_execute(sql, name, **options) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/db/active_record/adapter/postgres.rb', line 26

def raw_execute(sql, name, **options)
	log(sql, name) do
		connection = self.connect
		
		connection.send_query(sql)
		
		connection.next_result.to_a
	end
end