Class: ActivityPub::OutboxSerializer
Constant Summary
BaseSerializer::CONTEXT
Instance Attribute Summary
#options
Instance Method Summary
collapse
#as_json, #initialize, #to_json
Instance Method Details
#data ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/serializers/activitypub/outbox_serializer.rb', line 3
def data
result = {
id: object.id,
type: type
}
result[:totalItems] = total_items if object.size.present?
result[:next] = object.next if object.next.present?
result[:prev] = object.prev if object.prev.present?
result[:part_of] = object.part_of if object.part_of.present?
result[:first] = object.first if object.first.present?
result[:last] = object.last if object.last.present?
result[:items] = items if (!object.items.nil? || page?) && !ordered?
result[:ordered_items] = items if (!object.items.nil? || page?) && ordered?
result
end
|
#items ⇒ Object
35
36
37
|
# File 'app/serializers/activitypub/outbox_serializer.rb', line 35
def items
ActivityPub::StorySerializer.list(object.items).data
end
|
#total_items ⇒ Object
31
32
33
|
# File 'app/serializers/activitypub/outbox_serializer.rb', line 31
def total_items
object.size
end
|
#type ⇒ Object
23
24
25
26
27
28
29
|
# File 'app/serializers/activitypub/outbox_serializer.rb', line 23
def type
if page?
ordered? ? 'OrderedCollectionPage' : 'CollectionPage'
else
ordered? ? 'OrderedCollection' : 'Collection'
end
end
|