Sha256: 2a506a358649d432fd3d94b4dc1f8227501aa495023af841d6d2e5129731b83f

Contents?: true

Size: 710 Bytes

Versions: 12

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

module Lcms
  module Engine
    class DocumentMaterialSerializer < ActiveModel::Serializer
      attributes :data

      def initialize(document, materials)
        super(document)
        @document = document
        @materials = materials
      end

      def data
        ordered_ids = @document.ordered_material_ids
        anchors = @document.materials_anchors
        @materials
          .sort_by { |m| ordered_ids.index(m.id) }
          .map do |material|
          MaterialSerializer.new(
            DocumentGenerator.material_presenter.new material, document: @document, anchors: anchors[material.id] || []
          ).as_json
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.5.4 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.5.3 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.5.2 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.5.1 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.5.0 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.4.2 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.4.1 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.4.0 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.3.1 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.3.0 app/serializers/lcms/engine/document_material_serializer.rb
lcms-engine-0.2.0 app/serializers/lcms/engine/document_material_serializer.rb