dry_serialization 0.4.1 → 0.4.3.3

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: 8154638554abdc2750980b2a7e02616ec1ed918b61ea9437ef5d242788fb3673
4
- data.tar.gz: 6a3bccc9255e0beaeb3314c2ccf3c65154c3f3681c4aee1f1ea3206b75dec77a
3
+ metadata.gz: a1a7bb2bd8ce76221bceba243095ecbb4f7d05b290714fa0ff12e2d75448552f
4
+ data.tar.gz: 631820be97d5ed577abdd347724ac6e977c26f9fc2003dbe163c94ee44579707
5
5
  SHA512:
6
- metadata.gz: 1d04290d2ebb061f6b6f350c5c9243d8c096c86d95d82ac50d8aa7831410862773aaece337656287c41facb93b67302b63a82fe4a84bbe6e8794ad2aa026e0a5
7
- data.tar.gz: cba06d23936b7c61bcc053abb3ae196f7c726bf43790146e7eee95b3bbc1fa16fdc28224a3a99940e4812ff7f77fb6e7358ef3f73cecdfcc608512ae647a2027
6
+ metadata.gz: a5f9bd45173f5c1ce498de0ff57c8029997896b2b76ee2c4126938a9cca1b6b880fbf8e136bfff5d3af6a13b532089554d95bb85abbbab9efa422e68fc7fc756
7
+ data.tar.gz: a024336f7ec12f731f2a11623af105865da5d8ee46a231c488a605b25e169fbf696647ee756786c0935906644b6ae743f01fe3a321e5a2c12cfc16cd392e89ef
@@ -2,21 +2,22 @@ module DrySerialization
2
2
  module Concerns
3
3
  module SerializationHelper
4
4
  def success_response(data = {}, status = :ok)
5
- default_response = default_response(data, status)
6
- render json: default_response
5
+ render json: data, status: status
7
6
  end
8
-
7
+
9
8
  def error_response(errors, status = :unprocessable_entity)
10
9
  errors = [errors] unless errors.is_a?(Array)
11
- errors = { errors: errors }
12
- default_response = default_response(errors, status)
13
-
14
- render json: default_response
10
+ errors = handle_errors(errors)
11
+
12
+ render json: { errors: errors }, status: status
15
13
  end
16
14
 
17
- def default_response(data, status)
18
- { status: status }.merge(data)
15
+ private
16
+
17
+ def handle_errors(errors)
18
+ errors.each_with_object([]) { |error, acc| acc << { detail: error } }
19
19
  end
20
+
20
21
  end
21
22
  end
22
- end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module DrySerialization
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry_serialization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Heft
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-23 00:00:00.000000000 Z
11
+ date: 2020-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler