Sha256: 2b521484cd480f6f10f5473877ee8c7c6f556178fcebfcbe6dc3b52e7c8d0f48

Contents?: true

Size: 597 Bytes

Versions: 2

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

module Transmutation
  class CollectionSerializer # rubocop:disable Style/Documentation
    include Transmutation::Serialization

    def initialize(objects, namespace: "", serializer: nil)
      @objects = objects
      @namespace = namespace
      @serializer = serializer
    end

    def as_json(options = {})
      serializers = serialize(objects, namespace: namespace, serializer: serializer)

      serializers.map do |serializer|
        serializer.as_json(options)
      end
    end

    private

    attr_reader :objects, :namespace, :serializer
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
transmutation-0.1.1 lib/transmutation/collection_serializer.rb
transmutation-0.1.0 lib/transmutation/collection_serializer.rb