Sha256: 07066a74accff77df4258bc83a6948fcb727545ce2c7b0337f1f59a2a1daae08

Contents?: true

Size: 761 Bytes

Versions: 6

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

module RailsWorkflow
  class OperationHelperDecorator < Decorator
    include StatusDecorator
    delegate :id, :title, :tag, :instruction, :complete, :data

    def assigned_to
      object.assignment.try(:email) || begin
        [
          assignment_by_role, assignment_by_group
        ].compact.join(', ')
      end
    end

    def assignment_by_role
      ::User.role_text(object.role) if object.role
    end

    def assignment_by_group
      ::User.group_text(object.group) if object.group
    end

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

    def completed_at
      if object.completed_at.present?
        object.completed_at.strftime('%m/%d/%Y %H:%M')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails_workflow-0.7.3 app/decorators/rails_workflow/operation_helper_decorator.rb
rails_workflow-0.7.2 app/decorators/rails_workflow/operation_helper_decorator.rb
rails_workflow-0.7.1 app/decorators/rails_workflow/operation_helper_decorator.rb
rails_workflow-0.7.0 app/decorators/rails_workflow/operation_helper_decorator.rb
rails_workflow-0.4.4 app/decorators/rails_workflow/operation_helper_decorator.rb
rails_workflow-0.4.3 app/decorators/rails_workflow/operation_helper_decorator.rb