Class: Factbase::Inv

Inherits:
Object
  • Object
show all
Defined in:
lib/factbase/inv.rb

Overview

A decorator of a Factbase, that checks invariants on every set.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2024 Yegor Bugayenko

License

MIT

Defined Under Namespace

Classes: Fact, Query

Instance Method Summary collapse

Constructor Details

#initialize(fb, &block) ⇒ Inv

Returns a new instance of Inv.



34
35
36
37
# File 'lib/factbase/inv.rb', line 34

def initialize(fb, &block)
  @fb = fb
  @block = block
end

Instance Method Details

#dupObject



39
40
41
# File 'lib/factbase/inv.rb', line 39

def dup
  Factbase::Inv.new(@fb.dup, &@block)
end

#insertObject



43
44
45
# File 'lib/factbase/inv.rb', line 43

def insert
  Fact.new(@fb.insert, @block)
end

#query(query) ⇒ Object



47
48
49
# File 'lib/factbase/inv.rb', line 47

def query(query)
  Query.new(@fb.query(query), @block)
end

#txn(this = self) ⇒ Object



51
52
53
# File 'lib/factbase/inv.rb', line 51

def txn(this = self, &)
  @fb.txn(this, &)
end