Module: Textus::Workflow::DSL::Lifecycle

Included in:
Definition
Defined in:
lib/textus/workflow/dsl/lifecycle.rb

Constant Summary collapse

VALID_EXPIRE_ACTIONS =
%i[drop archive].freeze

Instance Method Summary collapse

Instance Method Details

#expire_action(action = :__no_arg__) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
# File 'lib/textus/workflow/dsl/lifecycle.rb', line 13

def expire_action(action = :__no_arg__)
  return nil if action == :__no_arg__

  sym = action.to_s.to_sym
  raise ArgumentError.new("on_expire must be one of drop|archive, got #{action.inspect}") unless VALID_EXPIRE_ACTIONS.include?(sym)

  sym
end

#max_attempts_value(n) ⇒ Object



22
23
24
# File 'lib/textus/workflow/dsl/lifecycle.rb', line 22

def max_attempts_value(n)
  n.to_i
end

#priority_value(n) ⇒ Object



26
27
28
# File 'lib/textus/workflow/dsl/lifecycle.rb', line 26

def priority_value(n)
  n.to_i
end

#ttl_value(cadence) ⇒ Object



7
8
9
10
11
# File 'lib/textus/workflow/dsl/lifecycle.rb', line 7

def ttl_value(cadence)
  return nil if cadence == :__no_arg__

  Textus::Value::Duration.seconds(cadence)
end