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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5597662d584540dd79caadc7cebd235f8a71d71f17fbbaf0395ea64b59606327
4
- data.tar.gz: 4a648b8b3a79dd0e368e19ce44587b2d0d1201212a8ce198860d985071461318
3
+ metadata.gz: 2cda384973ffc46850aa94c28c002f2e578d0bac1c4af1aad45457cdb5f0d125
4
+ data.tar.gz: ac249177ab532692368b7934f0c1d46c6fa30e41328b75b06530068daab0a47d
5
5
  SHA512:
6
- metadata.gz: 76eafbd90f13788bc0e3d0143c243abfb4e124d87bca6a4c98ada2093541e16cf7167ab2a66355003452c88ab2aa878fc8f801810d189afc77debe6f03af14f2
7
- data.tar.gz: ca410c5e8b49018155b14b73bd01c2042a390cdecbe39502c926b449dc4e74bd6da4f143244404cccab9ff3c5e6b30bc6b6566b780d62203353c5b13828ad346
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
- end
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "4.3.0"
4
+ VERSION = "4.3.1"
5
5
  end
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.0
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-07-06 00:00:00.000000000 Z
13
+ date: 2026-08-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord