Class: Dry::Transaction::Extra::PerformLater::ConfiguredJob
- Inherits:
-
Object
- Object
- Dry::Transaction::Extra::PerformLater::ConfiguredJob
- Defined in:
- lib/dry/transaction/extra/perform_later.rb
Instance Attribute Summary collapse
-
#job_class ⇒ Object
readonly
Returns the value of attribute job_class.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#transaction ⇒ Object
readonly
Returns the value of attribute transaction.
Instance Method Summary collapse
-
#initialize(job_class, transaction, options = {}) ⇒ ConfiguredJob
constructor
A new instance of ConfiguredJob.
- #perform_later(*args) ⇒ Object
- #validator ⇒ Object
Constructor Details
#initialize(job_class, transaction, options = {}) ⇒ ConfiguredJob
Returns a new instance of ConfiguredJob.
33 34 35 36 37 |
# File 'lib/dry/transaction/extra/perform_later.rb', line 33 def initialize(job_class, transaction, = {}) @job_class = job_class @transaction = transaction = end |
Instance Attribute Details
#job_class ⇒ Object (readonly)
Returns the value of attribute job_class.
31 32 33 |
# File 'lib/dry/transaction/extra/perform_later.rb', line 31 def job_class @job_class end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
31 32 33 |
# File 'lib/dry/transaction/extra/perform_later.rb', line 31 def end |
#transaction ⇒ Object (readonly)
Returns the value of attribute transaction.
31 32 33 |
# File 'lib/dry/transaction/extra/perform_later.rb', line 31 def transaction @transaction end |
Instance Method Details
#perform_later(*args) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dry/transaction/extra/perform_later.rb', line 39 def perform_later(*args) args.last.reverse_merge!([:perform_with]) if [:perform_with] if validator result = validator.new.call(*args).to_monad return result unless result.success? args = [result.value!.to_h] end Dry::Monads::Success( job_class.new(transaction_class_name: @transaction.name, args:) .enqueue() ) end |
#validator ⇒ Object
55 56 57 |
# File 'lib/dry/transaction/extra/perform_later.rb', line 55 def validator @transaction.validator end |