Class: ActivityPub::CollectionSerializer

Inherits:
BaseSerializer show all
Includes:
WithPagination
Defined in:
app/serializers/activity_pub/collection_serializer.rb

Overview

Serializer for the ‘Collection` ActivityStreams model. Reference: www.w3.org/TR/activitystreams-core/#collections

Direct Known Subclasses

ReleasesOutboxSerializer

Constant Summary collapse

NotPaginatedError =
Class.new(StandardError)

Instance Attribute Summary

Attributes included from WithPagination

#paginator

Attributes inherited from BaseSerializer

#params

Instance Method Summary collapse

Methods included from WithPagination

#paginated?, #with_pagination

Methods inherited from BaseSerializer

entity, #initialize

Constructor Details

This class inherits a constructor from BaseSerializer

Instance Method Details

#base_representObject



11
# File 'app/serializers/activity_pub/collection_serializer.rb', line 11

alias_method :base_represent, :represent

#represent(resources, opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/serializers/activity_pub/collection_serializer.rb', line 13

def represent(resources, opts = {})
  unless respond_to?(:paginated?) && paginated?
    raise NotPaginatedError, 'Pass #with_pagination to the serializer or use ActivityPub::ObjectSerializer instead'
  end

  response = if paginator.params['page'].present?
               represent_page(resources, paginator.params['page'].to_i, opts)
             else
               represent_pagination_index(resources)
             end

  HashWithIndifferentAccess.new(response)
end