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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cda384973ffc46850aa94c28c002f2e578d0bac1c4af1aad45457cdb5f0d125
4
- data.tar.gz: ac249177ab532692368b7934f0c1d46c6fa30e41328b75b06530068daab0a47d
3
+ metadata.gz: 930ab408c80afadb2064fa5476f4c0cd68130f13a7dd4303bf356194d0e4bed4
4
+ data.tar.gz: 1dca68c3804bf3ea9756e2d3a9054ca830ae79bbc8977d713a9d76f3eafef8cc
5
5
  SHA512:
6
- metadata.gz: ffcb3056724ef29a943f78352ed82260832ce285060f66c09f43713f163b28004bac79c099264a9c53ae0bbd2dc69906984c7e8e9837badac8fba961ea7a6647
7
- data.tar.gz: cc68358114f3de3f623a079e830cd7d1e73ec22fb5580c0c87435b9d4bcc99873d3d93fd154e36ee6436a86774174c74754e9b514e62a55ebd35b2fbbba1384d
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.set_callback(:initialize, :before, :switchman_assign_shard)
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
- 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
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "4.3.1"
4
+ VERSION = "4.3.2"
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.1
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-04 00:00:00.000000000 Z
13
+ date: 2026-08-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord