Class: JobWorkflow::Schedule

Inherits:
Object
  • Object
show all
Defined in:
lib/job_workflow/schedule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression:, class_name:, key: nil, queue: nil, priority: nil, args: {}, description: nil) ⇒ Schedule

rubocop:disable Metrics/ParameterLists : (

  expression: String,
  class_name: String,
  ?key: (String | Symbol)?,
  ?queue: String?,
  ?priority: Integer?,
  ?args: Hash[Symbol, untyped],
  ?description: String?
) -> void


23
24
25
26
27
28
29
30
31
# File 'lib/job_workflow/schedule.rb', line 23

def initialize(expression:, class_name:, key: nil, queue: nil, priority: nil, args: {}, description: nil)
  @expression = expression #: String
  @class_name = class_name #: String
  @key = (key || class_name).to_sym #: Symbol
  @queue = queue #: String?
  @priority = priority #: Integer?
  @args = args #: Hash[Symbol, untyped]
  @description = description #: String?
end

Instance Attribute Details

#argsObject (readonly)

: Hash[Symbol, untyped]



10
11
12
# File 'lib/job_workflow/schedule.rb', line 10

def args
  @args
end

#class_nameObject (readonly)

: String



6
7
8
# File 'lib/job_workflow/schedule.rb', line 6

def class_name
  @class_name
end

#descriptionObject (readonly)

: String?



11
12
13
# File 'lib/job_workflow/schedule.rb', line 11

def description
  @description
end

#expressionObject (readonly)

: String



7
8
9
# File 'lib/job_workflow/schedule.rb', line 7

def expression
  @expression
end

#keyObject (readonly)

: Symbol



5
6
7
# File 'lib/job_workflow/schedule.rb', line 5

def key
  @key
end

#priorityObject (readonly)

: Integer?



9
10
11
# File 'lib/job_workflow/schedule.rb', line 9

def priority
  @priority
end

#queueObject (readonly)

: String?



8
9
10
# File 'lib/job_workflow/schedule.rb', line 8

def queue
  @queue
end

Instance Method Details

#to_configObject

: () -> Hash[Symbol, untyped]



35
36
37
38
39
40
41
42
43
44
# File 'lib/job_workflow/schedule.rb', line 35

def to_config
  {
    class: class_name,
    schedule: expression,
    queue: queue,
    priority: priority,
    args: args.empty? ? nil : [args],
    description: description
  }.compact
end