Skip to content

Instantly share code, notes, and snippets.

@mperham
Created December 15, 2009 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mperham/257316 to your computer and use it in GitHub Desktop.
Save mperham/257316 to your computer and use it in GitHub Desktop.
def exists?(attribs)
CustomImage.find_by_account_id_and_hash(attribs['account_id'], attribs['id'])
end
# Cleaner way of doing the exists? and return/if without making the query twice?
# (the query can return nil so memoizing won't work)
def some_method(attribs)
img = exists?(attribs)
return img if img
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment