Class: Factbase::Pre
- Inherits:
-
Object
- Object
- Factbase::Pre
- Defined in:
- lib/factbase/pre.rb
Overview
A decorator of a Factbase, that runs a provided block on every insert
.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
- #dup ⇒ Object
- #export ⇒ Object
- #import(bytes) ⇒ Object
-
#initialize(fb, &block) ⇒ Pre
constructor
A new instance of Pre.
- #insert ⇒ Object
- #query(query) ⇒ Object
- #size ⇒ Object
- #txn(this = self) ⇒ Object
Constructor Details
#initialize(fb, &block) ⇒ Pre
Returns a new instance of Pre.
31 32 33 34 |
# File 'lib/factbase/pre.rb', line 31 def initialize(fb, &block) @fb = fb @block = block end |
Instance Method Details
#dup ⇒ Object
36 37 38 |
# File 'lib/factbase/pre.rb', line 36 def dup Factbase::Pre.new(@fb.dup, &@block) end |
#export ⇒ Object
58 59 60 |
# File 'lib/factbase/pre.rb', line 58 def export @fb.export end |
#import(bytes) ⇒ Object
62 63 64 |
# File 'lib/factbase/pre.rb', line 62 def import(bytes) @fb.import(bytes) end |
#insert ⇒ Object
44 45 46 47 48 |
# File 'lib/factbase/pre.rb', line 44 def insert f = @fb.insert @block.call(f) f end |
#query(query) ⇒ Object
50 51 52 |
# File 'lib/factbase/pre.rb', line 50 def query(query) @fb.query(query) end |
#size ⇒ Object
40 41 42 |
# File 'lib/factbase/pre.rb', line 40 def size @fb.size end |
#txn(this = self) ⇒ Object
54 55 56 |
# File 'lib/factbase/pre.rb', line 54 def txn(this = self, &) @fb.txn(this, &) end |