culturecode_stagehand 0.7.16 → 0.7.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stagehand/database.rb +13 -0
- data/lib/stagehand/staging/synchronizer.rb +5 -6
- data/lib/stagehand/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48752d8e1806f8baad891a8ce01dd27dd7dff724
|
4
|
+
data.tar.gz: ddae11cbab908b9068ee3ab8c4b3f1c77b069bd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2261be0f7fad6f70c400861596e665a7a9fa671dbfa170843486c5ea6e810b571834bc927c8827773ea25a6536c3e59e8dd11e9188f4137552aba2a9234dec05
|
7
|
+
data.tar.gz: 7fb87381e3fba33f2b64e223177052c45960a0ed5031853197876593dd30373b5a79c8c83ff0b66465321767e71c2d035a318e067c015bcb147f8dc24acdff9c
|
data/lib/stagehand/database.rb
CHANGED
@@ -55,6 +55,19 @@ module Stagehand
|
|
55
55
|
connect_to(current_connection_name) if different
|
56
56
|
end
|
57
57
|
|
58
|
+
def transaction
|
59
|
+
success = false
|
60
|
+
output = nil
|
61
|
+
ActiveRecord::Base.transaction do
|
62
|
+
Production::Record.transaction do
|
63
|
+
output = yield
|
64
|
+
success = true
|
65
|
+
end
|
66
|
+
raise ActiveRecord::Rollback unless success
|
67
|
+
end
|
68
|
+
return output
|
69
|
+
end
|
70
|
+
|
58
71
|
private
|
59
72
|
|
60
73
|
def connect_to(connection_name)
|
@@ -11,7 +11,7 @@ module Stagehand
|
|
11
11
|
def sync_now(&block)
|
12
12
|
raise SyncBlockRequired unless block_given?
|
13
13
|
|
14
|
-
|
14
|
+
Database.transaction do
|
15
15
|
checklist = Checklist.new(Commit.capture(&block).entries, :preconfirm_subject => false)
|
16
16
|
sync_checklist(checklist) unless checklist.requires_confirmation?
|
17
17
|
end
|
@@ -61,7 +61,7 @@ module Stagehand
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def sync_checklist(checklist)
|
64
|
-
|
64
|
+
Database.transaction do
|
65
65
|
sync_entries(checklist.syncing_entries)
|
66
66
|
CommitEntry.delete(checklist.affected_entries)
|
67
67
|
end
|
@@ -87,9 +87,8 @@ module Stagehand
|
|
87
87
|
# This confirmation is used to guard against writes to the record that occur after loading an initial list of
|
88
88
|
# entries that are autosyncable, but before the record is actually synced. To prevent this, a lock on the record
|
89
89
|
# is acquired and then the record's autosync eligibility is rechecked before calling the block.
|
90
|
-
# NOTE: This method must be called from within a transaction
|
91
90
|
def with_confirmed_autosyncability(entry, &block)
|
92
|
-
|
91
|
+
Database.transaction do
|
93
92
|
CommitEntry.connection.execute("SELECT 1 FROM #{entry.table_name} WHERE id = #{entry.record_id}")
|
94
93
|
block.call(entry) if autosyncable_entries(:record_id => entry.record_id, :table_name => entry.table_name).exists?
|
95
94
|
end
|
@@ -112,9 +111,9 @@ module Stagehand
|
|
112
111
|
if Configuration.single_connection?
|
113
112
|
next # Avoid deadlocking if the databases are the same
|
114
113
|
elsif entry.delete_operation?
|
115
|
-
|
114
|
+
Production.delete(entry)
|
116
115
|
elsif entry.save_operation?
|
117
|
-
|
116
|
+
Production.save(entry)
|
118
117
|
end
|
119
118
|
end
|
120
119
|
end
|
data/lib/stagehand/version.rb
CHANGED