Method: Puppy::TracedObject#method_missing
- Defined in:
- lib/puppy.rb
#method_missing(m, *args) ⇒ Object
Here it goes, every method invoked on this object will trigger TracedObject#method_missing since we’ve undefined every instance method. This will make us able to print method call and arguments, and then invoke the original method using Object#send on the original instance.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/puppy.rb', line 100 def method_missing( m, *args ) begin if ( @block == nil || @block.call( @object, m, *args ) == true ) && @is_puppy_traced == true @stream << '# ' @stream << ' ' * caller.size unless !@opts[:indent] as = @opts[:as] @stream << if as.is_a? Symbol @object.send as elsif as != nil as.to_s elsif @object.to_s end @stream << ".#{m}(#{args.map { |a| a.inspect }.join(', ')})" @stream << " [#{caller[0]}] " unless @opts[:caller] == false @stream << "\n" gets unless !@opts[:step] end @object.send m, *args rescue Exception => e raise end end |