Class: ManyfoldApi::V0::ModelListSerializer
- Inherits:
-
ApplicationSerializer
- Object
- ApplicationSerializer
- ManyfoldApi::V0::ModelListSerializer
- Defined in:
- app/serializers/manyfold_api/v0/model_list_serializer.rb
Instance Method Summary collapse
Methods inherited from ApplicationSerializer
#collection_ref, #context, #creator_ref, #file_ref, #group_ref, #initialize, #license, #model_ref, #ref, schema, schema_ref, schema_ref_name
Constructor Details
This class inherits a constructor from ManyfoldApi::V0::ApplicationSerializer
Instance Method Details
#serialize ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/serializers/manyfold_api/v0/model_list_serializer.rb', line 3 def serialize { "@context": context, "@id": Rails.application.routes.url_helpers.models_path, "@type": "hydra:Collection", totalItems: @object.total_count, member: @object.map { |model| model_ref(model).merge( name: model.name ) }, view: { "@id": Rails.application.routes.url_helpers.models_path(page: @object.current_page), "@type": "hydra:PartialCollectionView", first: Rails.application.routes.url_helpers.models_path(page: 1), previous: (Rails.application.routes.url_helpers.models_path(page: @object.prev_page) if @object.prev_page), next: (Rails.application.routes.url_helpers.models_path(page: @object.next_page) if @object.next_page), last: Rails.application.routes.url_helpers.models_path(page: @object.total_pages) }.compact } end |