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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1183871fbe98771c58abcc316bf0f38bdb631668
4
- data.tar.gz: 454bfdb1b9172646beee12f2fae8f8b7407aa6d7
3
+ metadata.gz: 200e399a5830497129bc96622521fb1babb4439a
4
+ data.tar.gz: 3e6e7b7f11eee794f26cb7716e82810b82c11256
5
5
  SHA512:
6
- metadata.gz: c5a94081106448d1522331b5ea27a66b8c9ccd5fdf99060f7943ca9f7e9a2b788826029b9c69ab506df77429901cc5da2db65bce5d7bf488ac73b759f7b18acc
7
- data.tar.gz: 6cb309410bc083aa6084a179dae0fd8a8bbf839a55294ba163001f1ea5acd43eeba2a3e0e57c83fbd5b9f83830b7ca1637f0118abfc980369186289f73f128d0
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 resource.valid?
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 resource.valid?
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
@@ -1,6 +1,6 @@
1
1
  module JsonApiResponders
2
2
  MAJOR = 2
3
- MINOR = 1
4
- PATCH = 3
3
+ MINOR = 2
4
+ PATCH = 0
5
5
  VERSION = [MAJOR, MINOR, PATCH].join('.').freeze
6
6
  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.1.3
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 00:00:00.000000000 Z
11
+ date: 2016-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler