Class: Pgtk::Spy
- Inherits:
-
Object
- Object
- Pgtk::Spy
- Defined in:
- lib/pgtk/spy.rb
Overview
A pool tha spies on another pool.
- Author
-
Yegor Bugayenko (yegor256@gmail.com)
- Copyright
-
Copyright © 2019-2025 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
- #exec(sql, *args) ⇒ Object
-
#initialize(pool, &block) ⇒ Spy
constructor
A new instance of Spy.
- #transaction ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(pool, &block) ⇒ Spy
Returns a new instance of Spy.
16 17 18 19 |
# File 'lib/pgtk/spy.rb', line 16 def initialize(pool, &block) @pool = pool @block = block end |
Instance Method Details
#exec(sql, *args) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/pgtk/spy.rb', line 25 def exec(sql, *args) start = Time.now ret = @pool.exec(sql, *args) @block&.call(sql.is_a?(Array) ? sql.join(' ') : sql, Time.now - start) ret end |
#transaction ⇒ Object
32 33 34 35 36 |
# File 'lib/pgtk/spy.rb', line 32 def transaction @pool.transaction do |t| yield Pgtk::Spy.new(t, &@block) end end |
#version ⇒ Object
21 22 23 |
# File 'lib/pgtk/spy.rb', line 21 def version @pool.version end |