Sha256: 487e5662a609ed27ed59af9f508198fbf8791b450fab5c3c24d52f7836debcc4

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module RailsWorkflow
  class ProcessDecorator < Decorator
    delegate_all

    include StatusDecorator

    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)
    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

1 entries across 1 versions & 1 rubygems

Version Path
rails_workflow-0.2.1 app/decorators/rails_workflow/process_decorator.rb