Class: JobWorkflow::TaskEnqueue
- Inherits:
-
Object
- Object
- JobWorkflow::TaskEnqueue
- Defined in:
- lib/job_workflow/task_enqueue.rb
Instance Attribute Summary collapse
-
#concurrency ⇒ Object
readonly
: Integer?.
-
#condition ⇒ Object
readonly
: true | false | ^(Context) -> bool.
-
#queue ⇒ Object
readonly
: String?.
Class Method Summary collapse
-
.from_primitive_value(value) ⇒ Object
: (true | false | ^(Context) -> bool | Hash[Symbol, untyped] | nil) -> TaskEnqueue.
Instance Method Summary collapse
-
#initialize(condition: false, queue: nil, concurrency: nil) ⇒ TaskEnqueue
constructor
: ( ?condition: true | false | ^(Context) -> bool, ?queue: String?, ?concurrency: Integer? ) -> void.
-
#should_enqueue?(context) ⇒ Boolean
: (Context) -> bool.
-
#should_limits_concurrency? ⇒ Boolean
: () -> bool.
Constructor Details
#initialize(condition: false, queue: nil, concurrency: nil) ⇒ TaskEnqueue
: (
?condition: true | false | ^(Context) -> bool,
?queue: String?,
?concurrency: Integer?
) -> void
32 33 34 35 36 |
# File 'lib/job_workflow/task_enqueue.rb', line 32 def initialize(condition: false, queue: nil, concurrency: nil) @condition = condition @queue = queue @concurrency = concurrency end |
Instance Attribute Details
#concurrency ⇒ Object (readonly)
: Integer?
7 8 9 |
# File 'lib/job_workflow/task_enqueue.rb', line 7 def concurrency @concurrency end |
#condition ⇒ Object (readonly)
: true | false | ^(Context) -> bool
5 6 7 |
# File 'lib/job_workflow/task_enqueue.rb', line 5 def condition @condition end |
#queue ⇒ Object (readonly)
: String?
6 7 8 |
# File 'lib/job_workflow/task_enqueue.rb', line 6 def queue @queue end |
Class Method Details
.from_primitive_value(value) ⇒ Object
: (true | false | ^(Context) -> bool | Hash[Symbol, untyped] | nil) -> TaskEnqueue
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/job_workflow/task_enqueue.rb', line 11 def from_primitive_value(value) case value when TrueClass, FalseClass, Proc new(condition: value) when Hash new( condition: value.fetch(:condition, !value.empty?), queue: value[:queue], concurrency: value[:concurrency] ) else new end end |
Instance Method Details
#should_enqueue?(context) ⇒ Boolean
: (Context) -> bool
39 40 41 42 43 |
# File 'lib/job_workflow/task_enqueue.rb', line 39 def should_enqueue?(context) return condition.call(context) if condition.is_a?(Proc) !!condition end |
#should_limits_concurrency? ⇒ Boolean
: () -> bool
46 47 48 |
# File 'lib/job_workflow/task_enqueue.rb', line 46 def should_limits_concurrency? !!condition && !concurrency.nil? && QueueAdapter.current.supports_concurrency_limits? end |