Class: JobWorkflow::TaskJobStatus
- Inherits:
-
Object
- Object
- JobWorkflow::TaskJobStatus
- Defined in:
- lib/job_workflow/task_job_status.rb
Instance Attribute Summary collapse
-
#each_index ⇒ Object
readonly
: Integer.
-
#job_id ⇒ Object
readonly
: String.
-
#status ⇒ Object
readonly
: Symbol.
-
#task_name ⇒ Object
readonly
: Symbol.
Class Method Summary collapse
-
.deserialize(hash) ⇒ Object
: (Hash[String, untyped]) -> TaskJobStatus.
-
.from_hash(hash) ⇒ Object
: (Hash[Symbol, untyped]) -> TaskJobStatus.
Instance Method Summary collapse
-
#failed? ⇒ Boolean
: () -> bool.
-
#finished? ⇒ Boolean
: () -> bool.
-
#initialize(task_name:, job_id:, each_index:, status: :pending) ⇒ TaskJobStatus
constructor
: ( task_name: Symbol, job_id: String, each_index: Integer, ?status: Symbol ) -> void.
-
#serialize ⇒ Object
: () -> Hash[String, untyped].
-
#succeeded? ⇒ Boolean
: () -> bool.
-
#update_status(status) ⇒ Object
: (Symbol) -> void.
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_index ⇒ Object (readonly)
: Integer
7 8 9 |
# File 'lib/job_workflow/task_job_status.rb', line 7 def each_index @each_index end |
#job_id ⇒ Object (readonly)
: String
6 7 8 |
# File 'lib/job_workflow/task_job_status.rb', line 6 def job_id @job_id end |
#status ⇒ Object (readonly)
: Symbol
8 9 10 |
# File 'lib/job_workflow/task_job_status.rb', line 8 def status @status end |
#task_name ⇒ Object (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
61 62 63 |
# File 'lib/job_workflow/task_job_status.rb', line 61 def failed? status == :failed end |
#finished? ⇒ Boolean
: () -> bool
51 52 53 |
# File 'lib/job_workflow/task_job_status.rb', line 51 def finished? %i[succeeded failed].include?(status) end |
#serialize ⇒ Object
: () -> 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
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 |