culturecode_stagehand 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '091f0329dd66eeb808a7a8efc8ee5741adf0b784'
|
|
4
|
+
data.tar.gz: 1f1fb675ec96bde1b1eba99dee37e32589bf3833
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f887b8666704eea9831568b093dfbcdbe7a53662f735b97fd07370563e9885ddcddf46d2a7aa070930a628e032ead9b9c2f65256723773875421a24927f129af
|
|
7
|
+
data.tar.gz: b0697843d0c5f03a3400e34114aa55448ed36c8e19f9a7ede070e2b9aa0d072ea353574703a2eb4be422fcdc761980f14de1c2a1fbb0a25061d8e8a63b331269
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
ActiveRecord::Base.class_eval do
|
|
2
2
|
# SYNC CALLBACKS
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def self.before_sync(method, options = {})
|
|
6
|
-
set_callback :sync, :before, method, options
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.after_sync(method, options = {})
|
|
10
|
-
set_callback :sync, :after, method, options
|
|
11
|
-
end
|
|
3
|
+
define_model_callbacks :sync, :sync_as_subject, :sync_as_affected
|
|
12
4
|
|
|
13
5
|
# SYNC STATUS
|
|
14
6
|
def self.inherited(subclass)
|
|
@@ -33,7 +33,7 @@ module Stagehand
|
|
|
33
33
|
|
|
34
34
|
Rails.logger.info "Syncing"
|
|
35
35
|
iterate_autosyncable_entries do |entry|
|
|
36
|
-
|
|
36
|
+
sync_entry(entry, :callbacks => :sync)
|
|
37
37
|
synced_count += 1
|
|
38
38
|
deleted_count += CommitEntry.matching(entry).delete_all
|
|
39
39
|
break if synced_count == limit
|
|
@@ -51,7 +51,7 @@ module Stagehand
|
|
|
51
51
|
break unless entries.present?
|
|
52
52
|
|
|
53
53
|
latest_entries = entries.uniq(&:key)
|
|
54
|
-
|
|
54
|
+
latest_entries.each {|entry| sync_entry(entry, :callbacks => :sync) }
|
|
55
55
|
Rails.logger.info "Synced #{latest_entries.count} entries"
|
|
56
56
|
|
|
57
57
|
deleted_count = CommitEntry.matching(latest_entries).delete_all
|
|
@@ -66,7 +66,14 @@ module Stagehand
|
|
|
66
66
|
|
|
67
67
|
def sync_checklist(checklist)
|
|
68
68
|
Database.transaction do
|
|
69
|
-
|
|
69
|
+
checklist.syncing_entries.each do |entry|
|
|
70
|
+
if checklist.subject_entries.include?(entry)
|
|
71
|
+
sync_entry(entry, :callbacks => [:sync, :sync_as_subject])
|
|
72
|
+
else
|
|
73
|
+
sync_entry(entry, :callbacks => [:sync, :sync_as_affected])
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
70
77
|
CommitEntry.delete(checklist.affected_entries)
|
|
71
78
|
end
|
|
72
79
|
end
|
|
@@ -106,25 +113,19 @@ module Stagehand
|
|
|
106
113
|
return entries
|
|
107
114
|
end
|
|
108
115
|
|
|
109
|
-
def
|
|
116
|
+
def sync_entry(entry, callbacks: [])
|
|
110
117
|
raise SchemaMismatch unless schemas_match?
|
|
111
118
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Production.delete(entry)
|
|
121
|
-
elsif entry.save_operation?
|
|
122
|
-
Production.save(entry)
|
|
123
|
-
end
|
|
119
|
+
run_sync_callbacks(entry, callbacks) do
|
|
120
|
+
Rails.logger.info "Synchronizing #{entry.table_name} #{entry.record_id}" if entry.content_operation?
|
|
121
|
+
if Configuration.single_connection?
|
|
122
|
+
next # Avoid deadlocking if the databases are the same
|
|
123
|
+
elsif entry.delete_operation?
|
|
124
|
+
Production.delete(entry)
|
|
125
|
+
elsif entry.save_operation?
|
|
126
|
+
Production.save(entry)
|
|
124
127
|
end
|
|
125
128
|
end
|
|
126
|
-
|
|
127
|
-
return entries.length
|
|
128
129
|
end
|
|
129
130
|
|
|
130
131
|
def schemas_match?
|
|
@@ -133,8 +134,13 @@ module Stagehand
|
|
|
133
134
|
return schemas_match
|
|
134
135
|
end
|
|
135
136
|
|
|
136
|
-
def run_sync_callbacks(entry, &block)
|
|
137
|
-
|
|
137
|
+
def run_sync_callbacks(entry, callbacks, &block)
|
|
138
|
+
callbacks = Array.wrap(callbacks).dup
|
|
139
|
+
return block.call unless entry.record && callbacks.present?
|
|
140
|
+
|
|
141
|
+
entry.record.run_callbacks(callbacks.shift) do
|
|
142
|
+
run_sync_callbacks(entry, callbacks, &block)
|
|
143
|
+
end
|
|
138
144
|
end
|
|
139
145
|
end
|
|
140
146
|
end
|
data/lib/stagehand/version.rb
CHANGED
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.12.
|
|
4
|
+
version: 0.12.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nicholas Jakobsen
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2017-01-
|
|
12
|
+
date: 2017-01-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|