Sha256: 498385048a1d9f8916c42587ea2b7f9af6e850579ba8f2eeb22d3c62f26aa7d5
Contents?: true
Size: 734 Bytes
Versions: 4
Compression:
Stored size: 734 Bytes
Contents
# frozen_string_literal: true module Lcms module Engine class DocumentMaterialSerializer < ActiveModel::Serializer self.root = false 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
4 entries across 4 versions & 1 rubygems