globalid 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/global_id/locator.rb +6 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15140d3d09fd236ea096c178a473440eb3d2fab55503978d646f3f13a863589c
4
- data.tar.gz: 65351562c30c6c4e68d5b21ac8a502a7f7f5c8995cf538844395d123c685afba
3
+ metadata.gz: 18495b4f7910329fd0a65dcfa294742d0cdbb129a4c7f6971c4f9c62e9ea890d
4
+ data.tar.gz: 5b6a25aabd0d04d9a4a2d4bb4d5152d68a67758fad96deabc011a4a169f2a055
5
5
  SHA512:
6
- metadata.gz: b2a642776d9233ad70854e49b1dde8287397b94321a158747abc6738c4a976a4bb93a5de9fa72d8e3f7792a5667cc01eb938200b0fb8da675bce28af8488c93d
7
- data.tar.gz: c390cbaf842ce68dfd97e4a6d94ae40f9b83fa694ee5931975d96d1b8bd4c8795fbb308a12d3e0ba54f5e8b87d16229a665abe86aa9d00ec0e5e98bb5777ad23
6
+ metadata.gz: fb525d60050154b885197a89aaf2b1f2f577d0574b83160a3c0cbc2899d67e8995cf23c2de852c30baaa1ef8cc594cad39187e3808b350195c95ead32359957c
7
+ data.tar.gz: 5dda5c09cffcc6e60da06931f3be5ba144db99f6ed0b9d7dc085633e0bac642f1c9d9ac7ba686dd59a6b9be64bb275ee8e78b39fae6e372b69c8131709db6f0f
@@ -190,14 +190,18 @@ class GlobalID
190
190
  model_class = model_class.includes(options[:includes]) if options[:includes]
191
191
 
192
192
  if options[:ignore_missing]
193
- model_class.where(model_class.primary_key => ids)
193
+ model_class.where(primary_key(model_class) => ids)
194
194
  else
195
195
  model_class.find(ids)
196
196
  end
197
197
  end
198
198
 
199
199
  def model_id_is_valid?(gid)
200
- Array(gid.model_id).size == Array(gid.model_class.primary_key).size
200
+ Array(gid.model_id).size == Array(primary_key(gid.model_class)).size
201
+ end
202
+
203
+ def primary_key(model_class)
204
+ model_class.respond_to?(:primary_key) ? model_class.primary_key : :id
201
205
  end
202
206
  end
203
207
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: globalid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-02 00:00:00.000000000 Z
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport