Class: Factbase::Tallied
- Inherits:
-
Object
- Object
- Factbase::Tallied
- Defined in:
- lib/factbase/tallied.rb
Overview
A decorator of a Factbase, that count all operations and then returns an instance of Factbase::Churn.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024-2025 Yegor Bugayenko
- License
-
MIT
Defined Under Namespace
Instance Attribute Summary collapse
-
#churn ⇒ Object
readonly
Returns the value of attribute churn.
Instance Method Summary collapse
-
#initialize(fb, churn = Factbase::Churn.new) ⇒ Tallied
constructor
A new instance of Tallied.
- #insert ⇒ Object
- #query(query, maps = nil) ⇒ Object
- #txn ⇒ Object
Constructor Details
Instance Attribute Details
#churn ⇒ Object (readonly)
Returns the value of attribute churn.
18 19 20 |
# File 'lib/factbase/tallied.rb', line 18 def churn @churn end |
Instance Method Details
#insert ⇒ Object
28 29 30 31 32 |
# File 'lib/factbase/tallied.rb', line 28 def insert f = Fact.new(@fb.insert, @churn) @churn.append(1, 0, 0) f end |
#query(query, maps = nil) ⇒ Object
34 35 36 |
# File 'lib/factbase/tallied.rb', line 34 def query(query, maps = nil) Query.new(@fb.query(query, maps), @churn, @fb) end |
#txn ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/factbase/tallied.rb', line 38 def txn before = @churn.dup commit = false @fb.txn do |fbt| catch :rollback do yield Factbase::Tallied.new(fbt, @churn) commit = true end rescue Factbase::Rollback => e @churn = before raise e ensure @churn = before unless commit end end |