Thursday, 21 May 2009

missing_method in Ruby

missing_method is one of cool features of Ruby.
Code:

class A
 def method_missing(name, *args)
   puts "Oops! \"#{name}\" method is missing"   
 end 
end

a = A.new
a.howdy
Output:
Oops! "howdy" method is missing
Rails ActiveRecord uses it for dynamic finders: here

Write first comment

Post a Comment