Class: LcpRuby::Workflow::Approval::StepDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/lcp_ruby/workflow/approval/step_definition.rb

Constant Summary collapse

VALID_ASSIGNMENTS =
%w[all claim single].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ StepDefinition

Returns a new instance of StepDefinition.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lcp_ruby/workflow/approval/step_definition.rb', line 9

def initialize(attrs = {})
  @name = attrs[:name].to_s
  @label = attrs[:label]&.to_s
  @approvers = attrs[:approvers] || {}
  @required = (attrs[:required] || 1).to_i
  @assignment = (attrs[:assignment] || "all").to_s
  @condition = attrs[:condition]
  @fallback = attrs[:fallback]

  validate!
end

Instance Attribute Details

#approversObject (readonly)

Returns the value of attribute approvers.



5
6
7
# File 'lib/lcp_ruby/workflow/approval/step_definition.rb', line 5

def approvers
  @approvers
end

#assignmentObject (readonly)

Returns the value of attribute assignment.



5
6
7
# File 'lib/lcp_ruby/workflow/approval/step_definition.rb', line 5

def assignment
  @assignment
end

#conditionObject (readonly)

Returns the value of attribute condition.



5
6
7
# File 'lib/lcp_ruby/workflow/approval/step_definition.rb', line 5

def condition
  @condition
end

#fallbackObject (readonly)

Returns the value of attribute fallback.



5
6
7
# File 'lib/lcp_ruby/workflow/approval/step_definition.rb', line 5

def fallback
  @fallback
end

#labelObject (readonly)

Returns the value of attribute label.



5
6
7
# File 'lib/lcp_ruby/workflow/approval/step_definition.rb', line 5

def label
  @label
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/lcp_ruby/workflow/approval/step_definition.rb', line 5

def name
  @name
end

#requiredObject (readonly)

Returns the value of attribute required.



5
6
7
# File 'lib/lcp_ruby/workflow/approval/step_definition.rb', line 5

def required
  @required
end

Class Method Details

.from_hash(hash) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lcp_ruby/workflow/approval/step_definition.rb', line 21

def self.from_hash(hash)
  hash = (hash || {}).transform_keys(&:to_s)
  new(
    name: hash["name"],
    label: hash["label"],
    approvers: hash["approvers"],
    required: hash["required"],
    assignment: hash["assignment"],
    condition: hash["condition"],
    fallback: hash["fallback"]
  )
end

Instance Method Details

#conditional?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/lcp_ruby/workflow/approval/step_definition.rb', line 34

def conditional?
  !@condition.nil?
end