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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 302e387a9951a4120fea323ca2f3eee13e8608963defa796c8ce0193ac1f2310
4
- data.tar.gz: 7adfed0108d9e3671eb83f3750babe622acb1470cc85447a74ab8519c9e41122
3
+ metadata.gz: e7cd3acf2bcf902cb1bbc73a89063a6f360b73bacb52e4764900ece3eaa5e08d
4
+ data.tar.gz: 67cf46933f34837e0d7b9730ff87cee2e785e4057adb9fa519f1e80150513a88
5
5
  SHA512:
6
- metadata.gz: 06d389b77e47f82dbcf6c3397c0e5c9b7d9b9fba124273e58d2a336d45c341317cb17ce0810e84c5cebf10ce51b12a0b26102a1600fa84e79f09fc42cb9fd89e
7
- data.tar.gz: '09ccf267a08bf2007aeb799ca521445fe25fbaa55ddabf1618577ef70f91b0baaff1bf0f622800d7dd9e2d210c8eaf2f401fa8dc847f72f45c950a4d74d974ab'
6
+ metadata.gz: a8ecd8b4dde1dfb4867c6532da43714d53662482b86f8a76b5adda396edba042d46cd1d1bdb2ed86590efbfb3f29c8946b37094621176c19690b738939affa97
7
+ data.tar.gz: ccb32bab9c54f998451f3b10ff1a0895ac06b07f6446ae8aafeb24cc32c10bca2672622790276ac9895b26ca9616a061fad359cf8ac7ac9835366138b248f091
@@ -41,47 +41,46 @@ module Wal
41
41
 
42
42
  def self.inherited(subclass)
43
43
  super
44
- @@change_callbacks = Hash.new { |hash, key| hash[key] = [] }
45
- @@delete_callbacks = Hash.new { |hash, key| hash[key] = [] }
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
- @@change_callbacks[table].push(only: [:create], block: block)
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
- @@change_callbacks[table].push(only: [:update], changed: changed&.map(&:to_s), block: block)
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
- @@change_callbacks[table].push(only: [:create, :update], changed: changed&.map(&:to_s), block: block)
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
- @@delete_callbacks[table].push(block: block)
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
- @@change_callbacks[event.full_table_name]
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
- @@change_callbacks[event.full_table_name]
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
- @@delete_callbacks[event.full_table_name].each do |callback|
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
- (@@change_callbacks.keys | @@delete_callbacks.keys).include? table
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wal
4
- VERSION = "0.0.21"
4
+ VERSION = "0.0.22"
5
5
  end
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.21
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-09 00:00:00.000000000 Z
10
+ date: 2025-10-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: pg