switchman 4.3.0 → 4.3.1
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 +18 -15
- 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: 2cda384973ffc46850aa94c28c002f2e578d0bac1c4af1aad45457cdb5f0d125
|
|
4
|
+
data.tar.gz: ac249177ab532692368b7934f0c1d46c6fa30e41328b75b06530068daab0a47d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ffcb3056724ef29a943f78352ed82260832ce285060f66c09f43713f163b28004bac79c099264a9c53ae0bbd2dc69906984c7e8e9837badac8fba961ea7a6647
|
|
7
|
+
data.tar.gz: cc68358114f3de3f623a079e830cd7d1e73ec22fb5580c0c87435b9d4bcc99873d3d93fd154e36ee6436a86774174c74754e9b514e62a55ebd35b2fbbba1384d
|
|
@@ -147,21 +147,7 @@ module Switchman
|
|
|
147
147
|
klass.scope :shadow, lambda { |key = primary_key|
|
|
148
148
|
where(key => QueryMethods::NonTransposingValue.new(Shard::IDS_PER_SHARD)..)
|
|
149
149
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
def _run_initialize_callbacks
|
|
153
|
-
@shard ||= if self.class.sharded_primary_key?
|
|
154
|
-
Shard.shard_for(self[self.class.primary_key], Shard.current(self.class.connection_class_for_self))
|
|
155
|
-
else
|
|
156
|
-
Shard.current(self.class.connection_class_for_self)
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
@loaded_from_shard ||= Shard.current(self.class.connection_class_for_self)
|
|
160
|
-
if shadow_record? && !Switchman.config[:writable_shadow_records]
|
|
161
|
-
@readonly = true
|
|
162
|
-
@readonly_from_shadow ||= true
|
|
163
|
-
end
|
|
164
|
-
super
|
|
150
|
+
klass.set_callback(:initialize, :before, :switchman_assign_shard)
|
|
165
151
|
end
|
|
166
152
|
|
|
167
153
|
def readonly!
|
|
@@ -332,6 +318,23 @@ module Switchman
|
|
|
332
318
|
|
|
333
319
|
private
|
|
334
320
|
|
|
321
|
+
def switchman_assign_shard
|
|
322
|
+
unless @shard && @loaded_from_shard
|
|
323
|
+
active_shard = Shard.current(self.class.connection_class_for_self)
|
|
324
|
+
@shard ||= if self.class.sharded_primary_key?
|
|
325
|
+
Shard.shard_for(self[self.class.primary_key], active_shard)
|
|
326
|
+
else
|
|
327
|
+
active_shard
|
|
328
|
+
end
|
|
329
|
+
@loaded_from_shard ||= active_shard
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
return unless shadow_record? && !Switchman.config[:writable_shadow_records]
|
|
333
|
+
|
|
334
|
+
@readonly = true
|
|
335
|
+
@readonly_from_shadow = true
|
|
336
|
+
end
|
|
337
|
+
|
|
335
338
|
def fallback_shard
|
|
336
339
|
Shard.current(self.class.connection_class_for_self) || Shard.default
|
|
337
340
|
end
|
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.1
|
|
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-
|
|
13
|
+
date: 2026-08-04 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activerecord
|