culturecode_stagehand 0.13.2 → 0.13.3
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 +4 -4
- data/lib/stagehand/production.rb +5 -0
- data/lib/stagehand/schema.rb +13 -10
- data/lib/stagehand/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ed3d3abf2a64c62d90182193fe80714d2bd8418
|
4
|
+
data.tar.gz: 4825e8a8e5621fc84020f57269589a4cea1ee04b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d4b00fbdf65ce78f0d930732b0cb1477e0fcb7d94c5f58008483c613fa7a72a14390e480b9d48912c45a3d43ba9f4f21707d11cc235b810ca3731fddf0c403e
|
7
|
+
data.tar.gz: edb00a7aa78d1c5f16f8eab425447790b53de432568531453908f7ce38c218abc617d47324b77239f043dc485327c32df730cf049305dde641b7b7bee4f82655
|
data/lib/stagehand/production.rb
CHANGED
@@ -20,12 +20,17 @@ module Stagehand
|
|
20
20
|
|
21
21
|
return unless attributes.present?
|
22
22
|
|
23
|
+
write(staging_record, attributes, table_name)
|
24
|
+
end
|
25
|
+
|
26
|
+
def write(staging_record, attributes, table_name = nil)
|
23
27
|
Connection.with_production_writes(Record) do
|
24
28
|
is_new = matching(staging_record, table_name).update_all(attributes).zero?
|
25
29
|
|
26
30
|
# Ensure we always return a record, even when updating instead of creating
|
27
31
|
Record.new.tap do |record|
|
28
32
|
record.assign_attributes(attributes)
|
33
|
+
record.id = Stagehand::Key.generate(staging_record, :table_name => table_name).last unless record.id
|
29
34
|
record.save if is_new
|
30
35
|
end
|
31
36
|
end
|
data/lib/stagehand/schema.rb
CHANGED
@@ -29,12 +29,7 @@ module Stagehand
|
|
29
29
|
|
30
30
|
def add_stagehand!(options = {})
|
31
31
|
ActiveRecord::Schema.define do
|
32
|
-
|
33
|
-
table_names -= UNTRACKED_TABLES
|
34
|
-
table_names -= Array(options[:except]).collect(&:to_s)
|
35
|
-
table_names &= Array(options[:only]).collect(&:to_s) if options[:only].present?
|
36
|
-
|
37
|
-
table_names.each do |table_name|
|
32
|
+
Stagehand::Schema.send :each_table, options do |table_name|
|
38
33
|
Stagehand::Schema.send :create_operation_trigger, table_name, 'insert', 'NEW'
|
39
34
|
Stagehand::Schema.send :create_operation_trigger, table_name, 'update', 'NEW'
|
40
35
|
Stagehand::Schema.send :create_operation_trigger, table_name, 'delete', 'OLD'
|
@@ -44,10 +39,7 @@ module Stagehand
|
|
44
39
|
|
45
40
|
def remove_stagehand!(options = {})
|
46
41
|
ActiveRecord::Schema.define do
|
47
|
-
|
48
|
-
table_names &= Array(options[:only]).collect(&:to_s) if options[:only].present?
|
49
|
-
|
50
|
-
table_names.each do |table_name|
|
42
|
+
Stagehand::Schema.send :each_table, options do |table_name|
|
51
43
|
Stagehand::Schema.send :drop_trigger, table_name, 'insert'
|
52
44
|
Stagehand::Schema.send :drop_trigger, table_name, 'update'
|
53
45
|
Stagehand::Schema.send :drop_trigger, table_name, 'delete'
|
@@ -69,6 +61,17 @@ module Stagehand
|
|
69
61
|
|
70
62
|
private
|
71
63
|
|
64
|
+
def each_table(options = {})
|
65
|
+
table_names = ActiveRecord::Base.connection.tables
|
66
|
+
table_names -= UNTRACKED_TABLES
|
67
|
+
table_names -= Array(options[:except]).collect(&:to_s)
|
68
|
+
table_names &= Array(options[:only]).collect(&:to_s) if options[:only].present?
|
69
|
+
|
70
|
+
table_names.each do |table_name|
|
71
|
+
yield table_name
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
72
75
|
# Create trigger to initialize session using a function
|
73
76
|
def create_session_trigger
|
74
77
|
drop_trigger(:stagehand_commit_entries, :insert)
|
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.13.
|
4
|
+
version: 0.13.3
|
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-
|
12
|
+
date: 2017-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|