Class: JobWorkflow::TaskContext
- Inherits:
-
Object
- Object
- JobWorkflow::TaskContext
- Defined in:
- lib/job_workflow/task_context.rb,
sig/generated/job_workflow/task_context.rbs
Constant Summary collapse
- NULL_VALUE =
nil
Instance Attribute Summary collapse
- #dry_run ⇒ Boolean
- #index ⇒ Integer
- #parent_job_id ⇒ String?
- #retry_count ⇒ Integer
- #task ⇒ Task?
- #value ⇒ Object
Class Method Summary collapse
-
.deserialize(hash) ⇒ TaskContext
: (Hash[String, untyped]) -> TaskContext.
Instance Method Summary collapse
-
#enabled? ⇒ Boolean
: () -> bool.
-
#initialize(task: nil, parent_job_id: nil, index: 0, value: nil, retry_count: 0, dry_run: false) ⇒ TaskContext
constructor
: ( ?task: Task?, ?parent_job_id: String?, ?index: Integer, ?value: untyped, ?retry_count: Integer, ?dry_run: bool ) -> void.
-
#serialize ⇒ Hash[String, untyped]
: () -> Hash[String, untyped].
Constructor Details
#initialize(task: nil, parent_job_id: nil, index: 0, value: nil, retry_count: 0, dry_run: false) ⇒ TaskContext
: ( ?task: Task?, ?parent_job_id: String?, ?index: Integer, ?value: untyped, ?retry_count: Integer, ?dry_run: bool ) -> void
36 37 38 39 40 41 42 43 |
# File 'lib/job_workflow/task_context.rb', line 36 def initialize(task: nil, parent_job_id: nil, index: 0, value: nil, retry_count: 0, dry_run: false) # rubocop:disable Metrics/ParameterLists self.task = task self.parent_job_id = parent_job_id self.index = index self.value = value self.retry_count = retry_count self.dry_run = dry_run end |
Instance Attribute Details
#dry_run ⇒ Boolean
13 14 15 |
# File 'lib/job_workflow/task_context.rb', line 13 def dry_run @dry_run end |
#index ⇒ Integer
10 11 12 |
# File 'lib/job_workflow/task_context.rb', line 10 def index @index end |
#parent_job_id ⇒ String?
9 10 11 |
# File 'lib/job_workflow/task_context.rb', line 9 def parent_job_id @parent_job_id end |
#retry_count ⇒ Integer
12 13 14 |
# File 'lib/job_workflow/task_context.rb', line 12 def retry_count @retry_count end |
#value ⇒ Object
11 12 13 |
# File 'lib/job_workflow/task_context.rb', line 11 def value @value end |
Class Method Details
.deserialize(hash) ⇒ TaskContext
: (Hash[String, untyped]) -> TaskContext
17 18 19 20 21 22 23 24 25 |
# File 'lib/job_workflow/task_context.rb', line 17 def deserialize(hash) new( task: hash["task"], parent_job_id: hash["parent_job_id"], index: hash["index"], value: ActiveJob::Arguments.deserialize([hash["value"]]).first, retry_count: hash.fetch("retry_count", 0) ) end |
Instance Method Details
#enabled? ⇒ Boolean
: () -> bool
46 47 48 |
# File 'lib/job_workflow/task_context.rb', line 46 def enabled? !parent_job_id.nil? end |
#serialize ⇒ Hash[String, untyped]
: () -> Hash[String, untyped]
51 52 53 54 55 56 57 58 59 |
# File 'lib/job_workflow/task_context.rb', line 51 def serialize { "task_name" => task&.task_name, "parent_job_id" => parent_job_id, "index" => index, "value" => ActiveJob::Arguments.serialize([value]).first, "retry_count" => retry_count } end |