Advertisement
saasbook

method_missing makes singulars work

Jan 22nd, 2012
4,438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.23 KB | None | 0 0
  1. # make singulars work
  2. class Numeric
  3.   def method_missing(method_id,*args,&block)  # capture all args in case need to call super
  4.     if method_id.to_s == 'euro'
  5.       self.send('euros')
  6.     else
  7.       super
  8.     end
  9.   end
  10. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement