Skip to content

Instantly share code, notes, and snippets.

@kenn
Created September 1, 2011 17: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 kenn/1186781 to your computer and use it in GitHub Desktop.
Save kenn/1186781 to your computer and use it in GitHub Desktop.
def to_hash(options={})
@to_hash ||= {
:id => self.id,
:created_at => self.created_at.iso8601
}.tap do |h|
if options[:details]
h.update(:user => self.user.to_hash(options.update(:owner => true)),
) if options[:details]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment