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
32
# 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



10
11
12
# File 'app/decorators/rails_workflow/process_decorator.rb', line 10

def context
  ContextDecorator.decorate object.context
end

#created_atObject



6
7
8
# File 'app/decorators/rails_workflow/process_decorator.rb', line 6

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

#future_operationsObject



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

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

end

#operationsObject



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

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