Sha256: a147872184d70c09b72d90b232dadfb9d1e1207fb699af7ad7a3edd45c797cac

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module RailsWorkflow
  class ProcessDecorator < Decorator
    include StatusDecorator
    delegate_all

    def created_at
      object.created_at.strftime('%m/%d/%Y %H:%M')
    end

    def context
      ContextDecorator.decorate object.context
    end

    def parents
      if object.parent_operation.present?
        [self.class.decorate(object.parent_operation.process)]
      else
        []
      end
    end

    def children
      children = object.operations.with_child_process.map(&:child_process)
      if children.present?
        self.class.decorate_collection(children)
      else
        []
      end
    end

    def operations
      OperationDecorator.decorate_collection(object.operations.order(:id))
    end

    def future_operations
      operations = if object.operations.present?
                     object.operations.map(&:template)
                   else
                     []
                   end
      OperationTemplateDecorator
        .decorate_collection(
          object.template.operations - operations
        )
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_workflow-0.7.3 app/decorators/rails_workflow/process_decorator.rb
rails_workflow-0.7.2 app/decorators/rails_workflow/process_decorator.rb
rails_workflow-0.7.1 app/decorators/rails_workflow/process_decorator.rb
rails_workflow-0.7.0 app/decorators/rails_workflow/process_decorator.rb
rails_workflow-0.4.4 app/decorators/rails_workflow/process_decorator.rb
rails_workflow-0.4.3 app/decorators/rails_workflow/process_decorator.rb
rails_workflow-0.4.2 app/decorators/rails_workflow/process_decorator.rb
rails_workflow-0.4.1 app/decorators/rails_workflow/process_decorator.rb
rails_workflow-0.4.0 app/decorators/rails_workflow/process_decorator.rb