switchman 4.3.1 → 4.3.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 +4 -4
- data/lib/switchman/active_record/base.rb +22 -10
- data/lib/switchman/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: 930ab408c80afadb2064fa5476f4c0cd68130f13a7dd4303bf356194d0e4bed4
|
|
4
|
+
data.tar.gz: 1dca68c3804bf3ea9756e2d3a9054ca830ae79bbc8977d713a9d76f3eafef8cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c0a3ab18976beb94b4e9a46efb7f24e503c66363d6354946c7156e1221ffacafdc364c7bcc61205092801508ab6a329caf00c2c95592426a467b5cab86692e7
|
|
7
|
+
data.tar.gz: 94e9b98dfd1453eb967d02fe4a07c0cdbf4c4fdb04258da291994c9e04e3ac55c0bd4e1d214de9a0c6cfa4c10fe1b8d1476cc6509f27369f45abff1f997aadaf
|
|
@@ -135,6 +135,18 @@ module Switchman
|
|
|
135
135
|
|
|
136
136
|
Shard.default
|
|
137
137
|
end
|
|
138
|
+
|
|
139
|
+
def inherited(subclass)
|
|
140
|
+
super
|
|
141
|
+
subclass.prepend(InitializeShard)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
module InitializeShard
|
|
146
|
+
def _run_initialize_callbacks(&)
|
|
147
|
+
switchman_assign_shard
|
|
148
|
+
super
|
|
149
|
+
end
|
|
138
150
|
end
|
|
139
151
|
|
|
140
152
|
def self.prepended(klass)
|
|
@@ -147,7 +159,7 @@ module Switchman
|
|
|
147
159
|
klass.scope :shadow, lambda { |key = primary_key|
|
|
148
160
|
where(key => QueryMethods::NonTransposingValue.new(Shard::IDS_PER_SHARD)..)
|
|
149
161
|
}
|
|
150
|
-
klass.
|
|
162
|
+
klass.descendants.each { |d| d.prepend(InitializeShard) }
|
|
151
163
|
end
|
|
152
164
|
|
|
153
165
|
def readonly!
|
|
@@ -319,15 +331,15 @@ module Switchman
|
|
|
319
331
|
private
|
|
320
332
|
|
|
321
333
|
def switchman_assign_shard
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
334
|
+
return if @shard && @loaded_from_shard
|
|
335
|
+
|
|
336
|
+
active_shard = Shard.current(self.class.connection_class_for_self)
|
|
337
|
+
@shard ||= if self.class.sharded_primary_key?
|
|
338
|
+
Shard.shard_for(self[self.class.primary_key], active_shard)
|
|
339
|
+
else
|
|
340
|
+
active_shard
|
|
341
|
+
end
|
|
342
|
+
@loaded_from_shard ||= active_shard
|
|
331
343
|
|
|
332
344
|
return unless shadow_record? && !Switchman.config[:writable_shadow_records]
|
|
333
345
|
|
data/lib/switchman/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: switchman
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.3.
|
|
4
|
+
version: 4.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cody Cutrer
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2026-08-
|
|
13
|
+
date: 2026-08-19 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activerecord
|