Skip to content

Instantly share code, notes, and snippets.

@shwoodard
Created March 1, 2009 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shwoodard/72435 to your computer and use it in GitHub Desktop.
Save shwoodard/72435 to your computer and use it in GitHub Desktop.
def value_for(resource, methods)
unless methods.is_a?(Array)
resource.respond_to?(methods) ? resource.send(methods) : ''
else
methods.inject(resource) {|resource, method| resource.respond_to?(method) ? resource.send(method) : ''}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment