Ruby - Metaprogramming Fundamentals
Identify the error in this Ruby class using respond_to_missing? and method_missing:
class Broken
def respond_to_missing?(method_name, include_private = false)
method_name.to_s.start_with?("do_")
end
def method_missing(method_name, *args)
"Doing #{method_name}"
end
end
b = Broken.new
puts b.do_something
puts b.unknown