Class: RailsWorkflow::ProcessDecorator

Inherits:
Decorator
  • Object
show all
Includes:
StatusDecorator
Defined in:
app/decorators/rails_workflow/process_decorator.rb

Instance Method Summary collapse

Methods inherited from Decorator

collection_decorator_class

Instance Method Details

#childrenObject



24
25
26
27
28
29
30
31
# File 'app/decorators/rails_workflow/process_decorator.rb', line 24

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

#contextObject



12
13
14
# File 'app/decorators/rails_workflow/process_decorator.rb', line 12

def context
  ContextDecorator.decorate object.context
end

#created_atObject



8
9
10
# File 'app/decorators/rails_workflow/process_decorator.rb', line 8

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

#future_operationsObject



37
38
39
40
41
42
43
44
45
46
47
# File 'app/decorators/rails_workflow/process_decorator.rb', line 37

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

#operationsObject



33
34
35
# File 'app/decorators/rails_workflow/process_decorator.rb', line 33

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

#parentsObject



16
17
18
19
20
21
22
# File 'app/decorators/rails_workflow/process_decorator.rb', line 16

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