Sha256: 275a3266f5ae05cccabe4982734be313c2b2b5514e10d19099168f1b77708fb5

Contents?: true

Size: 548 Bytes

Versions: 44

Compression:

Stored size: 548 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).run
        end)

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

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-core-0.29.1 lib/decidim/exporters/json.rb
decidim-core-0.28.4 lib/decidim/exporters/json.rb
decidim-core-0.27.9 lib/decidim/exporters/json.rb
decidim-core-0.29.0 lib/decidim/exporters/json.rb
decidim-core-0.28.3 lib/decidim/exporters/json.rb
decidim-core-0.27.8 lib/decidim/exporters/json.rb
decidim-core-0.29.0.rc4 lib/decidim/exporters/json.rb
decidim-core-0.29.0.rc3 lib/decidim/exporters/json.rb
decidim-core-0.29.0.rc2 lib/decidim/exporters/json.rb
decidim-core-0.29.0.rc1 lib/decidim/exporters/json.rb
decidim-core-0.28.2 lib/decidim/exporters/json.rb
decidim-core-0.27.7 lib/decidim/exporters/json.rb
decidim-core-0.28.1 lib/decidim/exporters/json.rb
decidim-core-0.27.6 lib/decidim/exporters/json.rb
decidim-core-0.26.10 lib/decidim/exporters/json.rb
decidim-core-0.26.9 lib/decidim/exporters/json.rb
decidim-core-0.28.0 lib/decidim/exporters/json.rb
decidim-core-0.27.5 lib/decidim/exporters/json.rb
decidim-core-0.28.0.rc5 lib/decidim/exporters/json.rb
decidim-core-0.28.0.rc4 lib/decidim/exporters/json.rb