Class: JobWorkflow::TaskJobStatus

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task_name:, job_id:, each_index:, status: :pending) ⇒ TaskJobStatus

: (

  task_name: Symbol,
  job_id: String,
  each_index: Integer,
  ?status: Symbol
) -> void


38
39
40
41
42
43
# File 'lib/job_workflow/task_job_status.rb', line 38

def initialize(task_name:, job_id:, each_index:, status: :pending)
  @task_name = task_name
  @job_id = job_id
  @each_index = each_index
  @status = status
end

Instance Attribute Details

#each_indexObject (readonly)

: Integer



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

def each_index
  @each_index
end

#job_idObject (readonly)

: String



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

def job_id
  @job_id
end

#statusObject (readonly)

: Symbol



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

def status
  @status
end

#task_nameObject (readonly)

: Symbol



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

def task_name
  @task_name
end

Class Method Details

.deserialize(hash) ⇒ Object

: (Hash[String, untyped]) -> TaskJobStatus



22
23
24
25
26
27
28
29
# File 'lib/job_workflow/task_job_status.rb', line 22

def deserialize(hash)
  new(
    task_name: hash["task_name"].to_sym,
    job_id: hash["job_id"],
    each_index: hash["each_index"],
    status: hash["status"].to_sym
  )
end

.from_hash(hash) ⇒ Object

: (Hash[Symbol, untyped]) -> TaskJobStatus



12
13
14
15
16
17
18
19
# File 'lib/job_workflow/task_job_status.rb', line 12

def from_hash(hash)
  new(
    task_name: hash[:task_name],
    job_id: hash[:job_id],
    each_index: hash[:each_index],
    status: hash[:status]
  )
end

Instance Method Details

#failed?Boolean

: () -> bool

Returns:

  • (Boolean)


61
62
63
# File 'lib/job_workflow/task_job_status.rb', line 61

def failed?
  status == :failed
end

#finished?Boolean

: () -> bool

Returns:

  • (Boolean)


51
52
53
# File 'lib/job_workflow/task_job_status.rb', line 51

def finished?
  %i[succeeded failed].include?(status)
end

#serializeObject

: () -> Hash[String, untyped]



66
67
68
# File 'lib/job_workflow/task_job_status.rb', line 66

def serialize
  { "task_name" => task_name.to_s, "job_id" => job_id, "each_index" => each_index, "status" => status.to_s }
end

#succeeded?Boolean

: () -> bool

Returns:

  • (Boolean)


56
57
58
# File 'lib/job_workflow/task_job_status.rb', line 56

def succeeded?
  status == :succeeded
end

#update_status(status) ⇒ Object

: (Symbol) -> void



46
47
48
# File 'lib/job_workflow/task_job_status.rb', line 46

def update_status(status)
  @status = status
end