json_api_responders 2.1.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/json_api_responders/responder/actions.rb +15 -8
- data/lib/json_api_responders/version.rb +2 -2
- 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: 200e399a5830497129bc96622521fb1babb4439a
|
4
|
+
data.tar.gz: 3e6e7b7f11eee794f26cb7716e82810b82c11256
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52b66e6ad1823e222a2b12ee78ff147dda45b87ff085a47eadfbb439edfd99d340304d7390cf34d037978983c7aafd4053b2a47b2c179203d6365fe3f35c051b
|
7
|
+
data.tar.gz: 28b6d03dc79cc014aac159f5cc1058d17823d0fcc7fd170971374192110f39870da102f71cf53726a45d85728824f8eb7e5e6e941e782eecf27fc575e8d9cb43
|
@@ -14,22 +14,22 @@ module JsonApiResponders
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def respond_to_create_action
|
17
|
-
if
|
18
|
-
self.status ||= :created
|
19
|
-
render_resource
|
20
|
-
else
|
17
|
+
if has_errors?
|
21
18
|
self.status ||= :unprocessable_entity
|
22
19
|
render_error
|
20
|
+
else
|
21
|
+
self.status ||= :created
|
22
|
+
render_resource
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def respond_to_update_action
|
27
|
-
if
|
28
|
-
self.status ||= :ok
|
29
|
-
render_resource
|
30
|
-
else
|
27
|
+
if has_errors?
|
31
28
|
self.status ||= :unprocessable_entity
|
32
29
|
render_error
|
30
|
+
else
|
31
|
+
self.status ||= :ok
|
32
|
+
render_resource
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -45,6 +45,13 @@ module JsonApiResponders
|
|
45
45
|
def resource_render_options
|
46
46
|
render_options.merge(json: resource, **options)
|
47
47
|
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def has_errors?
|
52
|
+
resource.respond_to?(:errors) && resource.errors.any?
|
53
|
+
end
|
54
|
+
|
48
55
|
end
|
49
56
|
end
|
50
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_api_responders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanko Krtalić Rusendić
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|