2017-07-14 18:01:39 -07:00
|
|
|
# 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
|
|
|
|
|
2017-07-16 01:28:55 -07:00
|
|
|
attributes :id, :type, :total_items
|
2017-07-14 18:01:39 -07:00
|
|
|
|
|
|
|
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
|