Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 18th, 2012  |  syntax: None  |  size: 0.24 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class Object  
  2.   def try_chain(*args)    
  3.     arg    = args.shift
  4.     result = (args.size > 0 && self.class.methods.include?(:scopes)) ? self.try(arg).scoped : self.try(arg)
  5.     result.send (args.size > 1 ? :try_chain : :try), *args
  6.   end  
  7. end