Skip to content

Instantly share code, notes, and snippets.

@Marchino
Created June 20, 2011 08:20
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marchino/1035291 to your computer and use it in GitHub Desktop.
Save Marchino/1035291 to your computer and use it in GitHub Desktop.
Recursive send method for Ruby Objects
# Lets you call object.rsend('method1.method2.method3') instead of object.send('method1').send('method2).send('method3)
class Object
def rsend(method, *params)
method.to_s.split('.').inject(self) { |obj, mth| obj.send(mth.to_sym, *params) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment