Skip to content

Instantly share code, notes, and snippets.

@TheKidCoder
Created January 3, 2015 20:52
Show Gist options
  • Save TheKidCoder/d5c02b987af37b7fbafb to your computer and use it in GitHub Desktop.
Save TheKidCoder/d5c02b987af37b7fbafb to your computer and use it in GitHub Desktop.
Simple method call cascading.
def title
[:full_name, :first_name, :name].find {|meth| object.respond_to?(meth)}.tap {|meth| return object.method(meth).call}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment