Sha256: add9712d1e027a0267fbe97703505e0c574d3cfb2dddaec1d91b7eca5e47d603

Contents?: true

Size: 941 Bytes

Versions: 4

Compression:

Stored size: 941 Bytes

Contents

#--
# Copyright (c) 2023 Jeremy Hinegardner
# All rights reserved.  See LICENSE and/or COPYING for details.
#++

module ::Libsql
  #
  # A TraceTap receives tracing information from SQLite3. It receives the SQL
  # statement being executed as a +msg+ just before the statement first begins
  # executing.
  #
  # A TraceTap is a wrapper around another object and a method.  The Tap object
  # will receive the call to +trace+ and redirect that call to another object
  # and method.
  #
  class TraceTap

    attr_reader :delegate_obj
    attr_reader :delegate_method

    def initialize( wrapped_obj, send_to = 'trace' )
      unless wrapped_obj.respond_to?( send_to )
        raise ::Libsql::Error, "#{wrapped_obj.class.name} does not respond to #{send_to.to_s} "
      end

      @delegate_obj = wrapped_obj
      @delegate_method = send_to
    end

    def trace( msg )
      delegate_obj.send( delegate_method, msg )
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
libsql-0.1.0-x64-mingw-ucrt lib/libsql/trace_tap.rb
libsql-0.1.0-x64-mingw32 lib/libsql/trace_tap.rb
libsql-0.1.0-x86-mingw32 lib/libsql/trace_tap.rb
libsql-0.1.0 lib/libsql/trace_tap.rb