Module: AfterCommit

Defined in:
lib/after_commit.rb,
lib/after_commit/active_record.rb,
lib/after_commit/connection_adapters.rb

Defined Under Namespace

Modules: ActiveRecord, ConnectionAdapters, TestBypass

Class Method Summary collapse

Class Method Details

.cleanup(connection) ⇒ Object



46
47
48
49
50
51
# File 'lib/after_commit.rb', line 46

def self.cleanup(connection)
  Thread.current[:committed_records]            = {}
  Thread.current[:committed_records_on_create]  = {}
  Thread.current[:committed_records_on_update]  = {}
  Thread.current[:committed_records_on_destroy] = {}
end

.created_records(connection) ⇒ Object



26
27
28
29
# File 'lib/after_commit.rb', line 26

def self.created_records(connection)
  Thread.current[:committed_records_on_create] ||= {}
  Thread.current[:committed_records_on_create][connection.object_id] ||= []
end

.destroyed_records(connection) ⇒ Object



36
37
38
39
# File 'lib/after_commit.rb', line 36

def self.destroyed_records(connection)
  Thread.current[:committed_records_on_destroy] ||= {}
  Thread.current[:committed_records_on_destroy][connection.object_id] ||= []
end

.record(connection, record) ⇒ Object



2
3
4
5
6
# File 'lib/after_commit.rb', line 2

def self.record(connection, record)
  Thread.current[:committed_records] ||= {}
  Thread.current[:committed_records][connection.object_id] ||= []
  Thread.current[:committed_records][connection.object_id] << record
end

.record_created(connection, record) ⇒ Object



8
9
10
11
12
# File 'lib/after_commit.rb', line 8

def self.record_created(connection, record)
  Thread.current[:committed_records_on_create] ||= {}
  Thread.current[:committed_records_on_create][connection.object_id] ||= []
  Thread.current[:committed_records_on_create][connection.object_id] << record
end

.record_destroyed(connection, record) ⇒ Object



20
21
22
23
24
# File 'lib/after_commit.rb', line 20

def self.record_destroyed(connection, record)
  Thread.current[:committed_records_on_destroy] ||= {}
  Thread.current[:committed_records_on_destroy][connection.object_id] ||= []
  Thread.current[:committed_records_on_destroy][connection.object_id] << record
end

.record_updated(connection, record) ⇒ Object



14
15
16
17
18
# File 'lib/after_commit.rb', line 14

def self.record_updated(connection, record)
  Thread.current[:committed_records_on_update] ||= {}
  Thread.current[:committed_records_on_update][connection.object_id] ||= []
  Thread.current[:committed_records_on_update][connection.object_id] << record
end

.records(connection) ⇒ Object



41
42
43
44
# File 'lib/after_commit.rb', line 41

def self.records(connection)
  Thread.current[:committed_records] ||= {}
  Thread.current[:committed_records][connection.object_id] ||= []
end

.updated_records(connection) ⇒ Object



31
32
33
34
# File 'lib/after_commit.rb', line 31

def self.updated_records(connection)
  Thread.current[:committed_records_on_update] ||= {}
  Thread.current[:committed_records_on_update][connection.object_id] ||= []
end