Class: Igniter::Extensions::Contracts::Creator::WorkflowStep

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/extensions/contracts/creator/workflow_step.rb

Constant Summary collapse

VALID_STATUSES =
%i[complete ready needs_attention pending].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, status:, title:, summary:, hints: []) ⇒ WorkflowStep

Returns a new instance of WorkflowStep.



12
13
14
15
16
17
18
19
# File 'lib/igniter/extensions/contracts/creator/workflow_step.rb', line 12

def initialize(key:, status:, title:, summary:, hints: [])
  @key = key.to_sym
  @status = normalize_status(status)
  @title = title
  @summary = summary
  @hints = Array(hints).map(&:to_s).uniq.freeze
  freeze
end

Instance Attribute Details

#hintsObject (readonly)

Returns the value of attribute hints.



10
11
12
# File 'lib/igniter/extensions/contracts/creator/workflow_step.rb', line 10

def hints
  @hints
end

#keyObject (readonly)

Returns the value of attribute key.



10
11
12
# File 'lib/igniter/extensions/contracts/creator/workflow_step.rb', line 10

def key
  @key
end

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/igniter/extensions/contracts/creator/workflow_step.rb', line 10

def status
  @status
end

#summaryObject (readonly)

Returns the value of attribute summary.



10
11
12
# File 'lib/igniter/extensions/contracts/creator/workflow_step.rb', line 10

def summary
  @summary
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'lib/igniter/extensions/contracts/creator/workflow_step.rb', line 10

def title
  @title
end

Instance Method Details

#actionable?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/igniter/extensions/contracts/creator/workflow_step.rb', line 25

def actionable?
  %i[ready needs_attention].include?(status)
end

#complete?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/igniter/extensions/contracts/creator/workflow_step.rb', line 21

def complete?
  status == :complete
end

#to_hObject



29
30
31
32
33
34
35
36
37
# File 'lib/igniter/extensions/contracts/creator/workflow_step.rb', line 29

def to_h
  {
    key: key,
    status: status,
    title: title,
    summary: summary,
    hints: hints
  }
end