Sha256: 4222b42b2cbe25645918efeb370f94b566a8da02006ac241c71b74d79fb31402

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
rails_workflow-0.3.7 app/decorators/rails_workflow/process_decorator.rb
rails_workflow-0.3.6 app/decorators/rails_workflow/process_decorator.rb
rails_workflow-0.3.5 app/decorators/rails_workflow/process_decorator.rb