Class TracePoint
In: lib/more/facets/tracepoint.rb
Parent: Object

TracePoint

A TracePoint is a Binding with the addition of event information. Among other things, it functions very well as the join-point for Event-based AOP.

Usage

  TracePoint.trace { |tp|
    puts "#{tp.self.class}\t#{tp.called}\t#{tp.event}\t#{tp.return?}\t#{tp.back == tp.bind}"
  }

  1 + 1

produces

  Class   trace   return     true    false
  Object          line       false   false
  Fixnum  +       c-call     false   false
  Fixnum  +       c-return   false   false

Notes

You can‘t subclass Binding, so we delegate (which is better anyway).

Methods

===   active   active=   back   bind   called   callee   event?   event_map   eventless?   method_name   new   self   trace  

Constants

EVENT_MAP = { :all => ['call', 'c-call', 'return', 'c-return', 'line', 'class', 'end', 'raise'], :before => ['call', 'c-call'], :after => ['return', 'c-return'], :call => ['call'], :return => ['return'], :ccall => ['c-call'], :creturn => ['c-return'], :line => ['line'], :class => ['class'], :end => ['end'], :raise => ['raise']   methods for working with events

Attributes

back_binding  [RW]  — instance ——————-
binding  [RW]  — instance ——————-
event  [RW]  — instance ——————-

Public Class methods

Until Ruby has a built-in way to get the name of the calling method that information must be passed into the TracePoint.

Trace execution using a TracePoint.

Public Instance methods

For use in case conditions

shorthand for back_binding

shorthand for binding

called()

Alias for callee

Returns the name of the event‘s method. This could delegate to the binding if Ruby had an internal way to retrieve the current method name.

Is the trace point defined or undefined?

method_name()

Alias for called

Delegates "self" to the binding which in turn delegates the binding object.

[Validate]