dry_serialization 0.3 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fffe54a30bc7e0e3dcffda5ffd92c83362d98493bcd7d48e766867468f1a3cca
4
- data.tar.gz: 9143b1bca8c2f5738f7bc9c3ad142f883405c69518c4cb8c17f89006e045fb8f
3
+ metadata.gz: 90a445b57058169cbfcbc1320111c29db630285f4cdb2b2d8677dc6bf40efdd4
4
+ data.tar.gz: f96c09045f95e6b9d28bbc08a8c6ffc79f1c9026301c85e062fb97fcd0b5bbbd
5
5
  SHA512:
6
- metadata.gz: f00eaa9aa4055e0de5e20eaceda000b8509dc1ee53b5032251be9c2691f988c36b39ef9a7ea51c56668339612bb054125bf053907d78fb727fcea08700ee3fd1
7
- data.tar.gz: 5415bcd22ad6007f85b868da92dd5ae681884761dcc60f13c3758d4d80241d8806ced854dacd48e66591fe8f907e03687eb2ef5ed98a001c62b9ccaf90ddd330
6
+ metadata.gz: cb606bc1c012bbb4d0963cfc5df3ed4997da217bb8c7e49264261b89db7853f0811cafef908a8d2b61acb29d3e6bba568b504d11b217ac92d0999d1f5c2b8da0
7
+ data.tar.gz: 970b00e53f7306ef07f5ec563499c8de15a83d7feee525dec520531be0b125ec474b782c32785f5378a90e56bfdbe437a66eba88a26bd3b8389e5a3ff9f7e0f0
@@ -1,6 +1,7 @@
1
1
  require "dry_serialization/version"
2
2
  require "dry_serialization/blueprinter"
3
3
  require "dry_serialization/fast_jsonapi"
4
+ require "dry_serialization/concerns/serialization_helper"
4
5
 
5
6
  module DrySerialization
6
7
 
@@ -1,7 +1,9 @@
1
- module DrySerialization::Blueprinter
1
+ module DrySerialization
2
+ module Blueprinter
3
+
4
+ def serialized_resource(resource, blueprint, options = {})
5
+ JSON.parse(blueprint.render(resource, options), symbolize_names: true)
6
+ end
2
7
 
3
- def serialized_resource(resource, blueprint, options = {})
4
- JSON.parse(blueprint.render(resource, options), symbolize_names: true)
5
8
  end
6
-
7
9
  end
@@ -0,0 +1,23 @@
1
+ module DrySerialization
2
+ module Concerns
3
+ module SerializationHelper
4
+ def success_response(data = {}, status = :ok)
5
+ render json: data, status: status
6
+ end
7
+
8
+ def error_response(errors, status = :unprocessable_entity)
9
+ errors = [errors] unless errors.is_a?(Array)
10
+ errors = handle_errors(errors)
11
+
12
+ render json: errors, status: status
13
+ end
14
+
15
+ private
16
+
17
+ def handle_errors(*errors)
18
+ errors.each_with_object([]) { |error, acc| acc << { detail: error } }
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module DrySerialization
2
- VERSION = "0.3"
2
+ VERSION = "0.4.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.3'
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Heft
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-08 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
@@ -150,7 +150,7 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
- description:
153
+ description:
154
154
  email:
155
155
  - mikeheft@gmail.com
156
156
  executables: []
@@ -162,17 +162,18 @@ files:
162
162
  - dry_serialization.gemspec
163
163
  - lib/dry_serialization.rb
164
164
  - lib/dry_serialization/blueprinter.rb
165
+ - lib/dry_serialization/concerns/serialization_helper.rb
165
166
  - lib/dry_serialization/fast_jsonapi.rb
166
167
  - lib/dry_serialization/version.rb
167
168
  - lib/generators/base_generator.rb
168
169
  - lib/generators/dry_serialization/blueprinter/install_generator.rb
169
170
  - lib/generators/dry_serialization/fast_jsonapi/install_generator.rb
170
171
  - lib/generators/templates/api_controller.rb
171
- homepage:
172
+ homepage:
172
173
  licenses:
173
174
  - MIT
174
175
  metadata: {}
175
- post_install_message:
176
+ post_install_message:
176
177
  rdoc_options: []
177
178
  require_paths:
178
179
  - lib
@@ -187,8 +188,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
188
  - !ruby/object:Gem::Version
188
189
  version: '0'
189
190
  requirements: []
190
- rubygems_version: 3.0.8
191
- signing_key:
191
+ rubygems_version: 3.1.2
192
+ signing_key:
192
193
  specification_version: 4
193
194
  summary: Drys up serialized returns by passing in object, serializer, and an options
194
195
  hash