Sha256: f21305ad2afb6cc2bd368f5917d6222f8ba42c428c7b9aead4a134d29e5107d4
Contents?: true
Size: 966 Bytes
Versions: 5
Compression:
Stored size: 966 Bytes
Contents
class Class # # Trace the specified method calls (`meths`, as symbols) to descendends of this class (or all methods if `:*` is supplied). # Output is printed to $stderr. # def trace_messages_to(*meths) return unless $DEBUG tracers = Module.new parent = self $stderr.puts "[*] Tracing messages sent to #{parent} (messages: #{meths.join(", ")})" meths.each do |meth| case meth when :* tracers.define_method(:send) do |meth, *args, &block| p meth, args, block super(meth, *args, &block) end else tracers.define_method(meth) do |*args, &block| arg_names = args.map(&:inspect) arg_names << "&block" if block $stderr.puts "[*] #{parent}##{meth}(#{arg_names.join(", ")})" if block super(*args, &block) else super(*args) end end end end self.prepend(tracers) end end
Version data entries
5 entries across 5 versions & 1 rubygems