Guest User

Untitled

a guest
May 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. class MyApp < Thor
  2. def method_missing(meth, *args)
  3. namespaces = meth.to_s.split(':')
  4. task = namespaces.pop
  5.  
  6. possible_class = namespaces.map { |unclass| unclass.gsub(/(?:^|_)(.)/) { $1.upcase } }.join('::')
  7. if(klass = self.class.const_get(possible_class))
  8. klass.new.send(task, *args)
  9. end
  10. end
  11. end
Add Comment
Please, Sign In to add comment