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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38286b5f9333c0db58872b75ebb6bbded9cfa4da
4
- data.tar.gz: 26f901f9f273e6622a866f92da44c7a8f65e8b9d
3
+ metadata.gz: 48752d8e1806f8baad891a8ce01dd27dd7dff724
4
+ data.tar.gz: ddae11cbab908b9068ee3ab8c4b3f1c77b069bd9
5
5
  SHA512:
6
- metadata.gz: dd4a38e8b374c151d42818b77b7403f96917c1730330dd94b767fea1e38aa3d8ff74d1804fbe84c22e5d87cd9eafc0fd65a3e337d19de325cb0fb8a8664c3789
7
- data.tar.gz: 100c6686c5cdac790b96c60c13f1c56db9814a839f39bc196b5d3da3a53887caff9f559b2f5ca2db054e4031a0fdfdbe433f56e99664c6c7d887b3d03728115a
6
+ metadata.gz: 2261be0f7fad6f70c400861596e665a7a9fa671dbfa170843486c5ea6e810b571834bc927c8827773ea25a6536c3e59e8dd11e9188f4137552aba2a9234dec05
7
+ data.tar.gz: 7fb87381e3fba33f2b64e223177052c45960a0ed5031853197876593dd30373b5a79c8c83ff0b66465321767e71c2d035a318e067c015bcb147f8dc24acdff9c
@@ -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
- ActiveRecord::Base.transaction do
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
- ActiveRecord::Base.transaction do
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
- ActiveRecord::Base.transaction do
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
- Stagehand::Production.delete(entry)
114
+ Production.delete(entry)
116
115
  elsif entry.save_operation?
117
- Stagehand::Production.save(entry)
116
+ Production.save(entry)
118
117
  end
119
118
  end
120
119
  end
@@ -1,3 +1,3 @@
1
1
  module Stagehand
2
- VERSION = "0.7.16"
2
+ VERSION = "0.7.17"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: culturecode_stagehand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.16
4
+ version: 0.7.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen