Sha256: 2bc4de7760222ee94ba3307724e811d5259c2c82cfa63720a19e4ab548ecd573

Contents?: true

Size: 788 Bytes

Versions: 7

Compression:

Stored size: 788 Bytes

Contents

# frozen_string_literal: true

module RailsWorkflow
  class ProcessTemplateSerializer < ActiveModel::Serializer
    attributes :uuid, :title, :source,
               :manager_class, :process_class, :type,
               :partial_name, :version, :tag, :child_processes

    has_many :operations, serializer: RailsWorkflow::OperationTemplateSerializer

    def process_class
      object.read_attribute :process_class
    end

    def manager_class
      object.read_attribute :manager_class
    end

    def child_processes
      children = object.operations.map(&:child_process).compact.uniq
      unless children.blank?
        ActiveModel::ArraySerializer.new(
          children,
          each_serializer: ProcessTemplateSerializer
        ).as_json
      end || []
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_workflow-0.7.1 app/serializers/rails_workflow/process_template_serializer.rb
rails_workflow-0.7.0 app/serializers/rails_workflow/process_template_serializer.rb
rails_workflow-0.4.4 app/serializers/rails_workflow/process_template_serializer.rb
rails_workflow-0.4.3 app/serializers/rails_workflow/process_template_serializer.rb
rails_workflow-0.4.2 app/serializers/rails_workflow/process_template_serializer.rb
rails_workflow-0.4.1 app/serializers/rails_workflow/process_template_serializer.rb
rails_workflow-0.4.0 app/serializers/rails_workflow/process_template_serializer.rb