Class: ActiveRecord::Base::PromiscuousDeleteOperation

Inherits:
PromiscousOperation show all
Defined in:
lib/promiscuous/publisher/operation/active_record.rb

Instance Attribute Summary

Attributes inherited from Promiscuous::Publisher::Operation::NonPersistent

#instances

Attributes inherited from Promiscuous::Publisher::Operation::Base

#operation

Instance Method Summary collapse

Methods inherited from PromiscousOperation

#ensure_transaction!, #execute, #model, #operation_payloads, #transaction_context

Methods inherited from Promiscuous::Publisher::Operation::NonPersistent

#execute_instrumented, #operation_payloads, #query_dependencies

Methods inherited from Promiscuous::Publisher::Operation::Base

_acquire_lock, #acquire_op_lock, #dependencies_for, #dependency_for_op_lock, #ensure_op_still_locked, #execute, #execute_instrumented, #explain_operation, #generate_payload, #get_new_op_lock, #increment_dependencies, lock_options, #on_rabbitmq_confirm, #operation_payloads, #payload_for, #publish_payload_in_rabbitmq_async, #publish_payload_in_redis, #query_dependencies, rabbitmq_staging_set_key, #record_timestamp, #recover_db_operation, recover_locks, recover_operation, recover_operation_from_lock, recover_payloads_for_rabbitmq, #recovering?, #recovery_payload, register_recovery_mechanism, #release_op_lock, run_recovery_mechanisms, #should_instrument_query?, #trace_operation, #write_dependencies

Constructor Details

#initialize(arel, name, binds, options = {}) ⇒ PromiscuousDeleteOperation

Returns a new instance of PromiscuousDeleteOperation.



250
251
252
253
254
# File 'lib/promiscuous/publisher/operation/active_record.rb', line 250

def initialize(arel, name, binds, options={})
  super
  @operation = :destroy
  raise unless @arel.is_a?(Arel::DeleteManager)
end

Instance Method Details

#db_operation_and_selectObject



256
257
258
259
260
261
262
# File 'lib/promiscuous/publisher/operation/active_record.rb', line 256

def db_operation_and_select
  # TODO We only need the tracked attributes really (most likely, we just need ID)
  # XXX This is only supported by Postgres.
  @connection.exec_query("#{@connection.to_sql(@arel, @binds)} RETURNING *", @operation_name, @binds).tap do |result|
    @instances = result.map { |row| model.instantiate(row) }
  end.rows.size
end