Skip to content

Instantly share code, notes, and snippets.

@swarut
Created September 24, 2012 08:52
Show Gist options
  • Save swarut/3774995 to your computer and use it in GitHub Desktop.
Save swarut/3774995 to your computer and use it in GitHub Desktop.
Ruby : Caching processed value in an instance variable #cache #ruby #pattern
class UserParser
attr_reader :mentioned_users
def mention_users
@mentioned_users ||= <some processing>
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment