Class: ActivityPub::CollectionSerializer
- Inherits:
-
BaseSerializer
- Object
- BaseSerializer
- ActivityPub::CollectionSerializer
- 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
Constant Summary collapse
- NotPaginatedError =
Class.new(StandardError)
Instance Attribute Summary
Attributes included from WithPagination
Attributes inherited from BaseSerializer
Instance Method Summary collapse
Methods included from WithPagination
Methods inherited from BaseSerializer
Constructor Details
This class inherits a constructor from BaseSerializer
Instance Method Details
#base_represent ⇒ Object
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 |