Class: ActiveRecord::DestroyAssociationAsyncJob
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
self,
::ActiveJob::Base ,
::ActiveJob::Translation ,
::ActiveJob::Timezones ,
::ActiveJob::Logging ,
::ActiveJob::Instrumentation ,
::ActiveJob::Exceptions ,
::ActiveJob::Callbacks ,
::ActiveSupport::Callbacks ,
::ActiveJob::Execution ,
::ActiveSupport::Rescuable ,
::ActiveJob::Enqueuing ,
::ActiveJob::QueuePriority ,
::ActiveJob::QueueName ,
::ActiveJob::QueueAdapter ,
::ActiveJob::Core
|
|
Inherits: |
ActiveJob::Base
|
Defined in: | activerecord/lib/active_record/destroy_association_async_job.rb |
Overview
Job to destroy the records associated with a destroyed record in background.
Constant Summary
::ActiveSupport::Callbacks
- Included
::ActiveJob::Exceptions
- Included
Class Attribute Summary
::ActiveJob::Base
- Inherited
._queue_adapter, ._queue_adapter_name, .after_discard_procs, .after_discard_procs?, .enqueue_after_transaction_commit, .log_arguments, .log_arguments?, | |
.logger | Accepts a logger conforming to the interface of Log4r or the default Ruby |
.priority, .priority?, .queue_name, .queue_name?, .queue_name_delimiter, .queue_name_delimiter?, .queue_name_prefix, .queue_name_prefix?, .retry_jitter |
Class Method Summary
::ActiveSupport::DescendantsTracker
- Inherited
Instance Attribute Summary
::ActiveJob::Base
- Inherited
#after_discard_procs, #after_discard_procs?, #logger, #queue_adapter, #queue_name_prefix, #queue_name_prefix? |
::ActiveJob::Logging
- Included
::ActiveJob::Callbacks
- Included
::ActiveJob::Execution
- Included
::ActiveJob::Core
- Included
#arguments | Job arguments. |
#enqueue_error | Track any exceptions raised by the backend so callers can inspect the errors. |
#enqueued_at | Track when a job was enqueued. |
#exception_executions |
|
#executions | Number of times this job has been executed (which increments on every retry, like after an exception). |
#job_id | Job Identifier. |
#locale |
|
#priority= | Priority that the job will have (lower is more priority). |
#provider_job_id | ID optionally provided by adapter. |
#queue_name= | Queue in which the job will reside. |
#scheduled_at |
|
#serialized_arguments=, #successfully_enqueued?, | |
#timezone | Timezone to be used during the job. |
#arguments_serialized?, | |
#successfully_enqueued= | Track whether the adapter received the job successfully. |
Instance Method Summary
- #perform(owner_model_name: nil, owner_id: nil, association_class: nil, association_ids: nil, association_primary_key_column: nil, ensuring_owner_was_method: nil)
- #owner_destroyed?(owner, ensuring_owner_was_method) ⇒ Boolean private
::ActiveJob::Logging
- Included
::ActiveJob::Instrumentation
- Included
::ActiveJob::Exceptions
- Included
#retry_job | Reschedules the job to be re-executed. |
#determine_delay, #determine_jitter_for_delay, #executions_for, #run_after_discard_procs |
::ActiveSupport::Callbacks
- Included
#run_callbacks | Runs the callbacks for the given event. |
#halted_callback_hook | A hook invoked every time a before callback is halted. |
::ActiveJob::Execution
- Included
#perform, | |
#perform_now | Performs the job immediately. |
#_perform_job |
::ActiveSupport::Rescuable
- Included
#rescue_with_handler | Delegates to the class method, but uses the instance as the subject for rescue_from handlers (method calls, |
#handler_for_rescue | Internal handler lookup. |
::ActiveJob::Enqueuing
- Included
#enqueue | Enqueues the job to be performed by the queue adapter. |
#raw_enqueue |
::ActiveJob::QueuePriority
- Included
#priority | Returns the priority that the job will be created with. |
::ActiveJob::QueueName
- Included
#queue_name | Returns the name of the queue the job will be run on. |
::ActiveJob::Core
- Included
#deserialize | Attaches the stored job data to the current instance. |
#initialize | Creates a new job instance. |
#serialize | Returns a hash with the job data that can safely be passed to the queuing adapter. |
#deserialize_arguments, #deserialize_arguments_if_needed, #serialize_arguments, #serialize_arguments_if_needed, | |
#set | Configures the job with the given options. |
Instance Method Details
#owner_destroyed?(owner, ensuring_owner_was_method) ⇒ Boolean
(private)
# File 'activerecord/lib/active_record/destroy_association_async_job.rb', line 34
def owner_destroyed?(owner, ensuring_owner_was_method) !owner || (ensuring_owner_was_method && owner.public_send(ensuring_owner_was_method)) end
#perform(owner_model_name: nil, owner_id: nil, association_class: nil, association_ids: nil, association_primary_key_column: nil, ensuring_owner_was_method: nil)
[ GitHub ]# File 'activerecord/lib/active_record/destroy_association_async_job.rb', line 15
def perform( owner_model_name: nil, owner_id: nil, association_class: nil, association_ids: nil, association_primary_key_column: nil, ensuring_owner_was_method: nil ) association_model = association_class.constantize owner_class = owner_model_name.constantize owner = owner_class.find_by(owner_class.primary_key => [owner_id]) if !owner_destroyed?(owner, ensuring_owner_was_method) raise DestroyAssociationAsyncError, "owner record not destroyed" end association_model.where(association_primary_key_column => association_ids).find_each do |r| r.destroy end end