You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
496 B
27 lines
496 B
7 years ago
|
# frozen_string_literal: true
|
||
|
|
||
|
class ActivityPub::CollectionSerializer < ActiveModel::Serializer
|
||
|
def self.serializer_for(model, options)
|
||
|
return ActivityPub::ActivitySerializer if model.class.name == 'Status'
|
||
|
super
|
||
|
end
|
||
|
|
||
|
attributes :id, :type, :total_items,
|
||
|
:current
|
||
|
|
||
|
has_many :items, key: :ordered_items
|
||
|
|
||
|
def type
|
||
|
case object.type
|
||
|
when :ordered
|
||
|
'OrderedCollection'
|
||
|
else
|
||
|
'Collection'
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def total_items
|
||
|
object.size
|
||
|
end
|
||
|
end
|