Class: JobWorkflow::TaskEnqueue
- Inherits:
-
Object
- Object
- JobWorkflow::TaskEnqueue
- Defined in:
- lib/job_workflow/task_enqueue.rb
Instance Attribute Summary collapse
-
#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) ⇒ TaskEnqueue
constructor
: ( ?condition: true | false | ^(Context) -> bool, ?queue: String? ) -> void.
-
#should_enqueue?(context) ⇒ Boolean
: (Context) -> bool.
Constructor Details
#initialize(condition: false, queue: nil) ⇒ TaskEnqueue
: (
?condition: true | false | ^(Context) -> bool,
?queue: String?
) -> void
45 46 47 48 |
# File 'lib/job_workflow/task_enqueue.rb', line 45 def initialize(condition: false, queue: nil) @condition = condition @queue = queue end |
Instance Attribute Details
#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
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/job_workflow/task_enqueue.rb', line 10 def from_primitive_value(value) case value when TrueClass, FalseClass, Proc new(condition: value) when Hash validate_hash_keys!(value) new( condition: value.fetch(:condition, !value.empty?), queue: value[:queue] ) else new end end |
Instance Method Details
#should_enqueue?(context) ⇒ Boolean
: (Context) -> bool
51 52 53 54 55 |
# File 'lib/job_workflow/task_enqueue.rb', line 51 def should_enqueue?(context) return condition.call(context) if condition.is_a?(Proc) !!condition end |