wal 0.0.21 → 0.0.22
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/wal/record_watcher.rb +17 -18
- data/lib/wal/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7cd3acf2bcf902cb1bbc73a89063a6f360b73bacb52e4764900ece3eaa5e08d
|
|
4
|
+
data.tar.gz: 67cf46933f34837e0d7b9730ff87cee2e785e4057adb9fa519f1e80150513a88
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8ecd8b4dde1dfb4867c6532da43714d53662482b86f8a76b5adda396edba042d46cd1d1bdb2ed86590efbfb3f29c8946b37094621176c19690b738939affa97
|
|
7
|
+
data.tar.gz: ccb32bab9c54f998451f3b10ff1a0895ac06b07f6446ae8aafeb24cc32c10bca2672622790276ac9895b26ca9616a061fad359cf8ac7ac9835366138b248f091
|
data/lib/wal/record_watcher.rb
CHANGED
|
@@ -41,47 +41,46 @@ module Wal
|
|
|
41
41
|
|
|
42
42
|
def self.inherited(subclass)
|
|
43
43
|
super
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
subclass.class_eval do
|
|
45
|
+
def self.change_callbacks
|
|
46
|
+
@change_callbacks ||= Hash.new { |hash, key| hash[key] = [] }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.delete_callbacks
|
|
50
|
+
@delete_callbacks ||= Hash.new { |hash, key| hash[key] = [] }
|
|
51
|
+
end
|
|
52
|
+
end
|
|
46
53
|
end
|
|
47
54
|
|
|
48
55
|
def self.on_insert(table, &block)
|
|
49
56
|
table = table.is_a?(String) ? table : table.table_name
|
|
50
|
-
|
|
57
|
+
change_callbacks[table].push(only: [:create], block: block)
|
|
51
58
|
end
|
|
52
59
|
|
|
53
60
|
def self.on_update(table, changed: nil, &block)
|
|
54
61
|
table = table.is_a?(String) ? table : table.table_name
|
|
55
|
-
|
|
62
|
+
change_callbacks[table].push(only: [:update], changed: changed&.map(&:to_s), block: block)
|
|
56
63
|
end
|
|
57
64
|
|
|
58
65
|
def self.on_save(table, changed: nil, &block)
|
|
59
66
|
table = table.is_a?(String) ? table : table.table_name
|
|
60
|
-
|
|
67
|
+
change_callbacks[table].push(only: [:create, :update], changed: changed&.map(&:to_s), block: block)
|
|
61
68
|
end
|
|
62
69
|
|
|
63
70
|
def self.on_delete(table, &block)
|
|
64
71
|
table = table.is_a?(String) ? table : table.table_name
|
|
65
|
-
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def self.change_callbacks
|
|
69
|
-
@@change_callbacks
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def self.delete_callbacks
|
|
73
|
-
@@delete_callbacks
|
|
72
|
+
delete_callbacks[table].push(block: block)
|
|
74
73
|
end
|
|
75
74
|
|
|
76
75
|
def on_record_changed(event)
|
|
77
76
|
case event
|
|
78
77
|
when InsertEvent
|
|
79
|
-
|
|
78
|
+
self.class.change_callbacks[event.full_table_name]
|
|
80
79
|
.filter { |callback| callback[:only].include? :create }
|
|
81
80
|
.each { |callback| instance_exec(event, &callback[:block]) }
|
|
82
81
|
|
|
83
82
|
when UpdateEvent
|
|
84
|
-
|
|
83
|
+
self.class.change_callbacks[event.full_table_name]
|
|
85
84
|
.filter { |callback| callback[:only].include? :update }
|
|
86
85
|
.each do |callback|
|
|
87
86
|
if (attributes = callback[:changed])
|
|
@@ -92,14 +91,14 @@ module Wal
|
|
|
92
91
|
end
|
|
93
92
|
|
|
94
93
|
when DeleteEvent
|
|
95
|
-
|
|
94
|
+
self.class.delete_callbacks[event.full_table_name].each do |callback|
|
|
96
95
|
instance_exec(event, &callback[:block])
|
|
97
96
|
end
|
|
98
97
|
end
|
|
99
98
|
end
|
|
100
99
|
|
|
101
100
|
def should_watch_table?(table)
|
|
102
|
-
(
|
|
101
|
+
(self.class.change_callbacks.keys | self.class.delete_callbacks.keys).include? table
|
|
103
102
|
end
|
|
104
103
|
|
|
105
104
|
# `RecordWatcher` supports three processing strategies:
|
data/lib/wal/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.22
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rodrigo Navarro
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-10-
|
|
10
|
+
date: 2025-10-21 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: pg
|