switchman 3.5.18 → 3.5.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cdaed95d542d3c212685130e78318ab37685b8fbf757fa54bb4948d517c6da6
4
- data.tar.gz: 4326b2c5eccec1fea66ea9f0df42f2442239856330fd663138981dfcae1017ad
3
+ metadata.gz: c0df62cfbd91bd2c05864fbae14ed6f7090ff31c2fe8c4d3915956604f20532f
4
+ data.tar.gz: aa2f7a2aaabb1133136df74e596336a5cbc0273d035d30fc07a55bfb597810ab
5
5
  SHA512:
6
- metadata.gz: c03b4ee181f6bf4f0bdd002c00c743c41c94afae189e0e7a18dab7abeb6f79477ea9f330c33f3968f26278fec0e20b42f7364cd05c5192b59ef9095ac9afed32
7
- data.tar.gz: '09244d984c8116ed0d2596b2b4b9791bd0a95ad58d93879e08afbc0df3c470f3c71859c2d03089eea361fc8ea80f10762956891236767d127b1c5b97e8ff7062'
6
+ metadata.gz: b805a3291f0b67e1682c3f73cb78d2aba912afb40e981260671951147af4e577d05eb00cce9849569368543e9f5c683898193dc754bf3e83cb965e4d77b00808
7
+ data.tar.gz: 9d4dd4b68faf8596e85e291e6f0f55882645ca81a9225191235ebd2ecf20cc546378ce96bcefa0149d5f4794f15e27f95dde594643ba22e561306d60c3da51a4
@@ -291,14 +291,14 @@ module Switchman
291
291
  end
292
292
 
293
293
  module AutosaveAssociation
294
- def association_foreign_key_changed?(reflection, record, key)
295
- return false if reflection.through_reflection?
294
+ if ::Rails.version < "7.1"
295
+ def association_foreign_key_changed?(reflection, record, key)
296
+ return false if reflection.through_reflection?
296
297
 
297
- # have to use send instead of _read_attribute because sharding
298
- record.has_attribute?(reflection.foreign_key) && record.send(reflection.foreign_key) != key
299
- end
298
+ # have to use send instead of _read_attribute because sharding
299
+ record.has_attribute?(reflection.foreign_key) && record.send(reflection.foreign_key) != key
300
+ end
300
301
 
301
- if ::Rails.version < "7.1"
302
302
  def save_belongs_to_association(reflection)
303
303
  # this seems counter-intuitive, but the autosave code will assign to attribute bypassing switchman,
304
304
  # after reading the id attribute _without_ bypassing switchman. So we need Shard.current for the
@@ -306,6 +306,16 @@ module Switchman
306
306
  shard.activate(connection_class_for_self_for_reflection(reflection)) { super }
307
307
  end
308
308
  else
309
+ def association_foreign_key_changed?(reflection, record, key)
310
+ return false if reflection.through_reflection?
311
+
312
+ foreign_key = Array(reflection.foreign_key)
313
+ return false unless foreign_key.all? { |k| record._has_attribute?(k) }
314
+
315
+ # have to use send instead of _read_attribute because sharding
316
+ foreign_key.map { |k| record.send(k) } != Array(key)
317
+ end
318
+
309
319
  def save_belongs_to_association(reflection)
310
320
  association = association_instance_get(reflection.name)
311
321
  return unless association&.loaded? && !association.stale_target?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "3.5.18"
4
+ VERSION = "3.5.19"
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: 3.5.18
4
+ version: 3.5.19
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: 2024-01-17 00:00:00.000000000 Z
13
+ date: 2024-02-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -288,6 +288,7 @@ licenses:
288
288
  - MIT
289
289
  metadata:
290
290
  rubygems_mfa_required: 'true'
291
+ source_code_uri: https://github.com/instructure/switchman
291
292
  post_install_message:
292
293
  rdoc_options: []
293
294
  require_paths: