Created
December 22, 2010 14:59
-
-
Save jeroenvandijk/751614 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "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 | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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