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
#initialize(fb, churn = Factbase::Churn.new) ⇒ Tallied
Returns a new instance of Tallied.
20 21 22 23 24 |
# File 'lib/factbase/tallied.rb', line 20 def initialize(fb, churn = Factbase::Churn.new) raise 'The "fb" is nil' if fb.nil? @fb = fb @churn = churn end |
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 |
# File 'lib/factbase/tallied.rb', line 38 def txn @fb.txn do |fbt| yield Factbase::Tallied.new(fbt, @churn) end end |