Created
February 16, 2009 23:55
-
-
Save joho/65468 to your computer and use it in GitHub Desktop.
Proper english method calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def method_missing(meth, *args, &block) | |
proper_english = { 'colour' => 'color', | |
'pluralise' => 'pluralize', | |
'metre' => 'meter' } | |
american_method_name = proper_english[meth.to_s] | |
if american_method_name | |
puts "** Using the proper english to call method #{american_method_name}" | |
return self.send(american_method_name, *args, &block) | |
end | |
super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment