Class: Decidim::Exporters::JSON

Inherits:
Exporter
  • Object
show all
Defined in:
decidim-core/lib/decidim/exporters/json.rb

Overview

Exports a JSON version of a provided hash, given a collection and a Serializer.

Instance Method Summary collapse

Methods inherited from Exporter

#initialize

Constructor Details

This class inherits a constructor from Decidim::Exporters::Exporter

Instance Method Details

#exportObject

Public: Generates a JSON representation of a collection and a Serializer.

Returns an ExportData with the export.



14
15
16
17
18
19
20
# File 'decidim-core/lib/decidim/exporters/json.rb', line 14

def export
  data = ::JSON.pretty_generate(@collection.map do |resource|
    @serializer.new(resource).run
  end)

  ExportData.new(data, "json")
end