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 |
# File 'lib/pgtk/spy.rb', line 25 def exec(sql, *args) @block.call(sql) @pool.exec(sql, *args) end |
#transaction ⇒ Object
30 31 32 33 34 35 |
# File 'lib/pgtk/spy.rb', line 30 def transaction @block.call('txn') @pool.transaction do |t| yield Spy.new(t, @block) end end |
#version ⇒ Object
21 22 23 |
# File 'lib/pgtk/spy.rb', line 21 def version @pool.version end |