caprese 0.3.20 → 0.3.21
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/caprese/record/associated_validator.rb +10 -9
- data/lib/caprese/record.rb +1 -1
- data/lib/caprese/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7099eedd3a4b000bb8750e27d9fe55b02381e2e2
|
4
|
+
data.tar.gz: 6d8697e726e6b306c5091f22574daeb790c2d920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10a73eae7ff8a403c3f68946c476228dfda16b2cff0a4775b167d962e07e4ed6242d0ff946989c09d7fbbc1b75d6e412a6b31d8752d3675d80807f77f82f81a9
|
7
|
+
data.tar.gz: d4f5e94178e5e0d6a01bfe511f1337d50a49f9e4c2d6162686a7701ea810d9cb85bc13603cbfe7f87ac72d7527003b10f2e7a38c8a876ba23d3c337b51c5a8e3
|
data/CHANGELOG.md
CHANGED
@@ -117,3 +117,7 @@
|
|
117
117
|
* Add `Caprese::Controller#resource_type_aliases` method that returns object mapping type aliases to actual types for the application
|
118
118
|
* Add `Caprese::Record.caprese_field_aliases` method that returns object mapping field aliases to actual fields for the record
|
119
119
|
* Add `Caprese::Record.caprese_type` method that returns singular symbol indicating the type to use when serializing the record. (`Caprese::Serializer.json_api_key` now uses this.)
|
120
|
+
|
121
|
+
## 0.3.21
|
122
|
+
|
123
|
+
* Change `::Record.caprese_style_errors` to false by default so non-Caprese errors render normally
|
@@ -13,23 +13,24 @@ module Caprese
|
|
13
13
|
# [
|
14
14
|
# { "key"=>"not_found", "field"=>"attachment.file", "message"=>"Could not find a file at ..."}
|
15
15
|
# ]
|
16
|
-
class AssociatedValidator <
|
16
|
+
class AssociatedValidator < ActiveRecord::Validations::AssociatedValidator
|
17
17
|
def validate_each(record, attribute, value)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
if Caprese::Record.caprese_style_errors
|
19
|
+
Array(value).reject { |r| r.marked_for_destruction? || r.valid? }.each do |invalid_record|
|
20
|
+
invalid_record.errors.to_a.each do |error|
|
21
|
+
field_name = error.field ? "#{attribute}.#{error.field}" : attribute
|
22
|
+
record.errors.add(field_name, error.code, { t: error.t }.merge(value: invalid_record))
|
23
|
+
end
|
22
24
|
end
|
25
|
+
else
|
26
|
+
super
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
31
|
module ClassMethods
|
28
32
|
def validates_associated(*attr_names)
|
29
|
-
validates_with(
|
30
|
-
(Caprese::Record.caprese_style_errors ? Caprese::Record : ActiveRecord::Validations)::AssociatedValidator,
|
31
|
-
_merge_attributes(attr_names)
|
32
|
-
)
|
33
|
+
validates_with Caprese::Record::AssociatedValidator, _merge_attributes(attr_names)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
data/lib/caprese/record.rb
CHANGED
data/lib/caprese/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caprese
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Landgrebe
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-04-
|
13
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: active_model_serializers
|