effective_resources 2.9.1 → 2.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/validators/size_validator.rb +8 -2
- data/lib/effective_resources/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39969863270d4e8a60c93f0dd10f138a93936fa84958005d25ad1a6c2ab747dd
|
4
|
+
data.tar.gz: 3836b95d6616e55f9bcd9d0e1c859bf17e87ac0d78dcbd89a2cfd5fbb84fd32c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c5b1e1c914d649b9c56004066d21d2d3125a68246dc15c95934850f3e2ae68c4d6eb07e1d55c6d163c2de42bdab06340d26dbd3561273078496aa3a41b80e84
|
7
|
+
data.tar.gz: c7e7eb23d4363b1977147d7e26ff2481dadf83ecd7326616f95392df404fff13d9434ac40f8091e41d6d07199b0f9d62f1c6a21bba3252366f5484a90adb32e7
|
@@ -15,9 +15,15 @@ class SizeValidator < ActiveModel::EachValidator
|
|
15
15
|
max_size = options.try(:[], :less_than) || 2.megabytes
|
16
16
|
message = options.try(:[], :message) || "is too large, please upload a file smaller than #{max_size / 1.megabyte}MB"
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
blobs = value.try(:blobs) || value.try(:blob) || raise('unable to find blobs')
|
19
|
+
|
20
|
+
Array(blobs).each do |blob|
|
21
|
+
if blob.byte_size > max_size
|
22
|
+
record.errors.add(attribute, message)
|
23
|
+
break
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
27
|
+
true
|
22
28
|
end
|
23
29
|
end
|