Skip to content

Instantly share code, notes, and snippets.

@apeiros
Created March 11, 2009 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apeiros/77670 to your computer and use it in GitHub Desktop.
Save apeiros/77670 to your computer and use it in GitHub Desktop.
# include time matters
module CallInspectable
def self.included(by)
inherited_methods = by.public_instance_methods-by.public_instance_methods(false)
inherited_methods.sort.each { |name|
class_eval("def #{name}(*args); $stderr.puts \"Called '#{name}' in #{by}\"; super; end")
}
end
end
class Foo < Array
def bar; "bar"; end
include CallInspectable
end
a = Foo.new
puts "call []"
a[0]
puts "call bar"
a.bar
puts "end"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment