Sha256: cba799627acff47d586dea83a8a6e4e842ef52ab4b6a35242ce0234d9fde4db3

Contents?: true

Size: 553 Bytes

Versions: 1

Compression:

Stored size: 553 Bytes

Contents

# frozen_string_literal: true
require "json"

module Decidim
  module Exporters
    # Exports a JSON version of a provided hash, given a collection and a
    # Serializer.
    class JSON < Exporter
      # Public: Generates a JSON representation of a collection and a
      # Serializer.
      #
      # Returns an ExportData with the export.
      def export
        data = ::JSON.pretty_generate(@collection.map do |resource|
          @serializer.new(resource).serialize
        end)

        ExportData.new(data, "json")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-core-0.1.0 lib/decidim/exporters/json.rb