friendly_uuid 0.2.2 → 0.3.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/friendly_uuid.rb +17 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b514478880a8346e8a580801e873200e226560494037ad536f8bc3b9b3ed59d
4
- data.tar.gz: f1d774f024d9a73516898bbe2e18bb1b1413aece6b4f9d5a893aa55b5e3f6d95
3
+ metadata.gz: a30a5351eaad80263a47cdfe1bb76994bbb93c9e455c56a32dbafa232f71b49a
4
+ data.tar.gz: af3e8aa4a342a951e88626f2ca199f0017a63ba0a4fb9e5333d8f056720cdf9a
5
5
  SHA512:
6
- metadata.gz: 36cf698433555fc9a2d18a39d1771570f8d7c2f379242332e8e80a9d83b4192e0e05bc5dfa6bf2ea0c4b352ec3cd263d11e5eeec904112f6897cbede5cf05feb
7
- data.tar.gz: a950fc6963e6b0f5869274000d2f9a2d4a6eff4231a3921daf6d2207a0205f7064f2115b80024c04f98e73c8a36de4fc1ddae55c24933ee909e8065b33767769
6
+ metadata.gz: 28a9eb11b1c06bacf19406691661162d7056d9d20c318d92b5bb7becf09daf2796552070f3341d682e46accfd41bc0818a7b11374257fa61332ee8032672fcfd
7
+ data.tar.gz: 49b3acb11d0bd5209a34a163013a3083224f608164045fb1160d47bc1262d1c22f31196490858e215e8a53705e67fee2f6c56148ba4863a7cd1bd23fb9658414
@@ -20,12 +20,24 @@ module FriendlyUUID
20
20
  end
21
21
 
22
22
  module Class
23
- def find(id)
24
- super(self.expand(id))
23
+ def find(*ids)
24
+ super(self.expand(ids))
25
25
  end
26
26
 
27
- def expand(short_uuid)
28
- self.expand_to_record(short_uuid).id
27
+ def expand(short_uuids)
28
+ # If a single ID passed as a string
29
+ return self.expand_to_record(short_uuids).id if short_uuids.class == String
30
+
31
+ # If a single ID passed as a non-nested array
32
+ if short_uuids[0].class != Array && short_uuids.length == 1
33
+ return self.expand_to_record(short_uuids.join).id
34
+ end
35
+
36
+ short_uuids.flatten!
37
+
38
+ short_uuids.map do |uuid|
39
+ self.expand_to_record(uuid).id
40
+ end
29
41
  end
30
42
 
31
43
  def compact(uuid)
@@ -63,7 +75,7 @@ module FriendlyUUID
63
75
  when "postgresql"
64
76
  "LEFT(#{self.table_name}.id::text, ?) = ?"
65
77
  when "sqlite3"
66
- "SUBSTR(#{self.table_name}?.id, 0, ?) = ?"
78
+ "SUBSTR(#{self.table_name}.id, 0, ?) = ?"
67
79
  else
68
80
  raise ValueError("Unknown database type; FriendlyUUID cannot support it")
69
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendly_uuid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Carlsson