|
This post originated from an RSS feed registered with Ruby Buzz
by Ryan Davis.
|
Original Post: MuffDaddy! The Ultimate Rapper! (Word)
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
|
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Ryan Davis
Latest Posts From Polishing Ruby
|
|
module CheapoTracer
include MuffDaddy
RAP_METHOD_NAME = :__trace__
def __trace__
@__trace = 0 unless defined? @__trace
print " " * @__trace
print "#{@__trace}: "
@__trace += 1
yield
@__trace -= 1
end
end
class Untraced
def something
puts "Miiiiisery!"
something_else
end
def something_else
puts "Decay!"
end
end
class Traced
include CheapoTracer
def method1
puts "I'm dead too!"
end
end
w1 = Untraced.new
w1.something
w1.extend CheapoTracer
w1.something
w2 = Untraced.new
w2.something
w3 = Traced.new
w3.method1
outputs:
Miiiiisery!
Decay!
0: Miiiiisery!
1: Decay!
Miiiiisery!
Decay!
0: I'm dead too!
Read: MuffDaddy! The Ultimate Rapper! (Word)