Skip to content

Instantly share code, notes, and snippets.

@jeroenvandijk
Created December 22, 2010 14:59
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 jeroenvandijk/751614 to your computer and use it in GitHub Desktop.
Save jeroenvandijk/751614 to your computer and use it in GitHub Desktop.
{ "activities":
[
{
"id": 1,
"title": "likes your app x",
"actor": {
"type": "user",
"id": 3
},
"verbs": [
"post"
],
"object": {
"type": "comment",
"id": 1,
"content": "Vel voluptate aliquid et doloribus sint eum ad sequi."
},
"indirect_object": {
"type": "app",
"id": 1
}
}
]
}
collection(@activities) do |collection|
collection.members do |member, activity|
member.values { |values|
values.id activity.id
values.title activity.title
# ACTOR
values.actor :type => activity.actor_type.downcase, :id => activity.actor_id
# VERB
values.verbs activity.verbs
# OBJECT
object_hash = { :type => activity.object_type.downcase, :id => activity.object_id }
object_hash[:content] = activity.object.content if activity.object_content?
values.object object_hash
# Indirect OBJECT
if activity.indirect_object
indirect_object_hash = { :type => activity.indirect_object_type.downcase, :id => activity.indirect_object_id}
values.indirect_object indirect_object_hash
end
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment