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.

25 lines
473 B

  1. # frozen_string_literal: true
  2. class ActivityPub::CollectionSerializer < ActiveModel::Serializer
  3. def self.serializer_for(model, options)
  4. return ActivityPub::ActivitySerializer if model.class.name == 'Status'
  5. super
  6. end
  7. attributes :id, :type, :total_items
  8. has_many :items, key: :ordered_items
  9. def type
  10. case object.type
  11. when :ordered
  12. 'OrderedCollection'
  13. else
  14. 'Collection'
  15. end
  16. end
  17. def total_items
  18. object.size
  19. end
  20. end