lib/trace_spy/method.rb
def enable
      @tracepoint = TracePoint.new do |trace|
        begin
          next unless matches?(trace)

          @current_trace = trace

          call_with  = -> with { -> spy { spy.call(with) } }


          @spies[:arguments].each(&call_with[extract_args(trace)])    if CALL_EVENT.include?(trace.event)
          @spies[:locals].each(&call_with[extract_locals(trace)])     if LINE_EVENT.include?(trace.event)
          @spies[:return].each(&call_with[trace.return_value])        if RETURN_EVENT.include?(trace.event)
          @spies[:exception].each(&call_with[trace.raised_exception]) if RAISE_EVENT.include?(trace.event)

          @current_trace = nil
        rescue RuntimeError => e
          # Stupid hack for now
          p e
        end
      end

      @tracepoint.enable
    end
# "Enables" the current tracepoint by defining it, caching it, and enabling it
#
# @since 0.0.1
#
# @return [FalseClass]
#   Still not sure why TracePoint#enable returns `false`, but here we are
"Enables" the current tracepoint by defining it, caching it, and enabling it
" Enables " the current tracepoint by defining it caching it and enabling it
def enable
      @tracepoint = TracePoint.new do |trace|
        begin
          next unless matches?(trace)
          @current_trace = trace
          call_with  = -> with { -> spy { spy.call(with) } }
          @spies[:arguments].each(&call_with[extract_args(trace)])    if CALL_EVENT.include?(trace.event)
          @spies[:locals].each(&call_with[extract_locals(trace)])     if LINE_EVENT.include?(trace.event)
          @spies[:return].each(&call_with[trace.return_value])        if RETURN_EVENT.include?(trace.event)
          @spies[:exception].each(&call_with[trace.raised_exception]) if RAISE_EVENT.include?(trace.event)
          @current_trace = nil
        rescue RuntimeError => e
          p e
        end
      end
      @tracepoint.enable
    end
def enable @tracepoint = TracePoint . new do | trace | begin next unless matches? ( trace ) @current_trace = trace call_with = -> with { -> spy { spy . call ( with ) } } @spies [ :arguments ] . each ( & call_with [ extract_args ( trace ) ] ) if CALL_EVENT . include? ( trace . event ) @spies [ :locals ] . each ( & call_with [ extract_locals ( trace ) ] ) if LINE_EVENT . include? ( trace . event ) @spies [ :return ] . each ( & call_with [ trace . return_value ] ) if RETURN_EVENT . include? ( trace . event ) @spies [ :exception ] . each ( & call_with [ trace . raised_exception ] ) if RAISE_EVENT . include? ( trace . event ) @current_trace = nil rescue RuntimeError => e p e end end @tracepoint . enable end
"Enables" the current tracepoint by defining it, caching it, and enabling it
" Enables " the current tracepoint by defining it caching it and enabling it
# Stupid hack for now
Still not sure why TracePoint#enable returns `false`, but here we are
Still not sure why TracePoint#enable returns ` false ` but here we are
FalseClass
since
None