Class: Factbase::Looged

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

Overview

A decorator of a Factbase, that logs all operations.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2024 Yegor Bugayenko

License

MIT

Defined Under Namespace

Classes: Fact, Query

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fb, loog) ⇒ Looged

Returns a new instance of Looged.



31
32
33
34
# File 'lib/factbase/looged.rb', line 31

def initialize(fb, loog)
  @fb = fb
  @loog = loog
end

Class Method Details

.elapsedObject



160
161
162
163
164
# File 'lib/factbase/looged.rb', line 160

def self.elapsed
  start = Time.now
  yield
  "in #{format('%.2f', (Time.now - start) * 1000)}ms"
end

Instance Method Details

#dupObject



36
37
38
# File 'lib/factbase/looged.rb', line 36

def dup
  Factbase::Looged.new(@fb.dup, @loog)
end

#exportObject



58
59
60
# File 'lib/factbase/looged.rb', line 58

def export
  @fb.export
end

#import(bytes) ⇒ Object



62
63
64
# File 'lib/factbase/looged.rb', line 62

def import(bytes)
  @fb.import(bytes)
end

#insertObject



44
45
46
47
48
# File 'lib/factbase/looged.rb', line 44

def insert
  f = @fb.insert
  @loog.debug("Inserted new fact ##{@fb.size}")
  Fact.new(f, @loog)
end

#query(query) ⇒ Object



50
51
52
# File 'lib/factbase/looged.rb', line 50

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

#sizeObject



40
41
42
# File 'lib/factbase/looged.rb', line 40

def size
  @fb.size
end

#txn(this = self) ⇒ Object



54
55
56
# File 'lib/factbase/looged.rb', line 54

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