lib/factbase/looged.rb in factbase-0.0.52 vs lib/factbase/looged.rb in factbase-0.0.53

- old
+ new

@@ -18,10 +18,11 @@ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +require 'others' require 'time' require 'loog' require 'tago' require_relative 'syntax' @@ -29,22 +30,22 @@ # Author:: Yegor Bugayenko (yegor256@gmail.com) # Copyright:: Copyright (c) 2024 Yegor Bugayenko # License:: MIT class Factbase::Looged def initialize(fb, loog) + raise 'The "fb" is nil' if fb.nil? @fb = fb + raise 'The "loog" is nil' if loog.nil? @loog = loog end + decoor(:fb) + def dup Factbase::Looged.new(@fb.dup, @loog) end - def size - @fb.size - end - def insert f = @fb.insert @loog.debug("Inserted new fact ##{@fb.size}") Fact.new(f, @loog) end @@ -70,18 +71,10 @@ @loog.debug("Txn ##{id} #{r ? 'modified' : 'didn\'t touch'} the factbase in #{start.ago}") end r end - def export - @fb.export - end - - def import(bytes) - @fb.import(bytes) - end - # Fact decorator. # # This is an internal class, it is not supposed to be instantiated directly. # class Fact @@ -90,32 +83,18 @@ def initialize(fact, loog) @fact = fact @loog = loog end - def to_s - @fact.to_s - end - - def method_missing(*args) + others do |*args| r = @fact.method_missing(*args) k = args[0].to_s v = args[1] s = v.is_a?(Time) ? v.utc.iso8601 : v.to_s s = v.to_s.inspect if v.is_a?(String) s = "#{s[0..MAX_LENGTH / 2]}...#{s[-MAX_LENGTH / 2..]}" if s.length > MAX_LENGTH @loog.debug("Set '#{k[0..-2]}' to #{s} (#{v.class})") if k.end_with?('=') r - end - - # rubocop:disable Style/OptionalBooleanParameter - def respond_to?(_method, _include_private = false) - # rubocop:enable Style/OptionalBooleanParameter - true - end - - def respond_to_missing?(_method, _include_private = false) - true end end # Query decorator. #