uuid_associations-active_record 0.3.0 → 0.3.1

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: 7bd48c49180664455d830bf4877bab4a57001cba97d710d0ec104753c71a456c
4
- data.tar.gz: e6259cc8ef51b92bc456b00cf89839c088823567afc8de1d605440c85e79b5d7
3
+ metadata.gz: c995c046ef0be0f3b711654edcda1b8beaa005c20114c221196c112e60908140
4
+ data.tar.gz: a7296028dc5b9ce6c48884ec9c34baffe72523aa770d13cca785f77393ea562e
5
5
  SHA512:
6
- metadata.gz: 8e94d8ffa58e122b70e09f60b9031de98510cb9452fa4b98a11f5b8225cb7474e995eb8dd1cff8e40efbf43ea05ac4e45b34a8211ae9a28f749352f16a61764e
7
- data.tar.gz: 510166b160fc1c19ce2ac78215d92169246f64e41c335583e905110f5ed3aa205101aea8f308bb65105a6643f162b84b2d31ffe107d4a9e66310e1dd32dd41d0
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
- raise ::ActiveRecord::RecordNotFound.new(
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
@@ -1,5 +1,5 @@
1
1
  module UuidAssociations
2
2
  module ActiveRecord
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.3.1'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uuid_associations-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Celi