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
- #empty? ⇒ Boolean
- #export ⇒ Object
- #import(bytes) ⇒ Object
-
#initialize(fb, &block) ⇒ Pre
constructor
A new instance of Pre.
- #insert ⇒ Object
- #query(query) ⇒ Object
- #size ⇒ Object
- #to_json(opt = nil) ⇒ Object
- #to_xml ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(fb, &block) ⇒ Pre
Returns a new instance of Pre.
30 31 32 33 |
# File 'lib/factbase/pre.rb', line 30 def initialize(fb, &block) @fb = fb @block = block end |
Instance Method Details
#empty? ⇒ Boolean
35 36 37 |
# File 'lib/factbase/pre.rb', line 35 def empty? @fb.empty? end |
#export ⇒ Object
53 54 55 |
# File 'lib/factbase/pre.rb', line 53 def export @fb.export end |
#import(bytes) ⇒ Object
57 58 59 |
# File 'lib/factbase/pre.rb', line 57 def import(bytes) @fb.import(bytes) end |
#insert ⇒ Object
43 44 45 46 47 |
# File 'lib/factbase/pre.rb', line 43 def insert f = @fb.insert @block.call(f) f end |
#query(query) ⇒ Object
49 50 51 |
# File 'lib/factbase/pre.rb', line 49 def query(query) @fb.query(query) end |
#size ⇒ Object
39 40 41 |
# File 'lib/factbase/pre.rb', line 39 def size @fb.size end |
#to_json(opt = nil) ⇒ Object
61 62 63 |
# File 'lib/factbase/pre.rb', line 61 def to_json(opt = nil) @fb.to_json(opt) end |
#to_xml ⇒ Object
65 66 67 |
# File 'lib/factbase/pre.rb', line 65 def to_xml @fb.to_xml end |
#to_yaml ⇒ Object
69 70 71 |
# File 'lib/factbase/pre.rb', line 69 def to_yaml @fb.to_yaml end |