Class: Decidim::Pages::PageSerializer
- Inherits:
-
Exporters::Serializer
- Object
- Exporters::Serializer
- Decidim::Pages::PageSerializer
- Includes:
- ApplicationHelper, ResourceHelper
- Defined in:
- lib/decidim/pages/page_serializer.rb
Overview
This class serializes a Page so can be exported to CSV, JSON or other formats.
Instance Method Summary collapse
-
#initialize(page) ⇒ PageSerializer
constructor
Public: Initializes the serializer with a page.
-
#serialize ⇒ Object
Public: Exports a hash with the serialized data for this page.
Constructor Details
#initialize(page) ⇒ PageSerializer
Public: Initializes the serializer with a page.
12 13 14 |
# File 'lib/decidim/pages/page_serializer.rb', line 12 def initialize(page) @page = page end |
Instance Method Details
#serialize ⇒ Object
Public: Exports a hash with the serialized data for this page.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/decidim/pages/page_serializer.rb', line 17 def serialize { id: page.id, title: page.title, body: page.body, created_at: page.created_at, updated_at: page.updated_at, participatory_space: { id: page.participatory_space.id, url: Decidim::ResourceLocatorPresenter.new(page.participatory_space).url }, component: { id: component.id }, url: } end |