uuid_associations-active_record 0.3.0 → 0.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c995c046ef0be0f3b711654edcda1b8beaa005c20114c221196c112e60908140
|
|
4
|
+
data.tar.gz: a7296028dc5b9ce6c48884ec9c34baffe72523aa770d13cca785f77393ea562e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6261c2250b8201c8530732e09bcdafffd40f08f4e18a970c89c75adf69f0321944eabfb0194ae73027a61106d27cc7b140c6868a62a757e5c7bec3b7701ae7eb
|
|
7
|
+
data.tar.gz: d0d2d8dd24b7c3ed82cbb3138f710c635519f45560acdd8e0a12996e5a5126b59aa01d8de9cd5ecb6493796f1ee18f0b4da7cba2d8efc78a6ddb35a49bf24aba
|
|
@@ -27,9 +27,7 @@ module UuidAssociations
|
|
|
27
27
|
record = found_records.find { |found_record| found_record.uuid == uuid }
|
|
28
28
|
|
|
29
29
|
if record.blank?
|
|
30
|
-
|
|
31
|
-
"Couldn't find #{association_klass.name} with UUID=#{uuid}", association_klass, :id, uuid
|
|
32
|
-
)
|
|
30
|
+
raise_not_found_error(uuid)
|
|
33
31
|
end
|
|
34
32
|
|
|
35
33
|
collection << attributes.merge(id: record.id)
|
|
@@ -44,6 +42,16 @@ module UuidAssociations
|
|
|
44
42
|
@attribute_collection.instance_of?(Hash) ? @attribute_collection.values : @attribute_collection
|
|
45
43
|
end
|
|
46
44
|
|
|
45
|
+
def raise_not_found_error(uuid)
|
|
46
|
+
if ::ActiveRecord.version < Gem::Version.new('5.0')
|
|
47
|
+
raise ::ActiveRecord::RecordNotFound, "Couldn't find #{association_klass.name} with UUID=#{uuid}"
|
|
48
|
+
else
|
|
49
|
+
raise ::ActiveRecord::RecordNotFound.new(
|
|
50
|
+
"Couldn't find #{association_klass.name} with UUID=#{uuid}", association_klass, :id, uuid
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
47
55
|
attr_reader :association_klass
|
|
48
56
|
end
|
|
49
57
|
end
|