dry_serialization 0.4.2 → 0.4.4

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: d459a861acc9de313bcab71122b336f30d34666a3411400e4cb54bea9183fbf3
4
- data.tar.gz: 2a81afbac8b773d22afb9bd0707472a08404e35d482ee6e495442f4ae4fa7982
3
+ metadata.gz: b221770696640aabe5ea67ea242040f7ed1835fb84419c2ba49b248a3529c8ef
4
+ data.tar.gz: 951c23dd578c6b49cf7cc75ffe020e102dea1b4d5a20474be670f09496be57dd
5
5
  SHA512:
6
- metadata.gz: 4d40cd9fd0eed6bfa27bbd405db14839215d456b6c5d32712338c8947be74fabb6e9c6ec92c4a45dce44aee0e5934aa3788aec4463067fe233f4cde53ce29a72
7
- data.tar.gz: c048532d1db6519248e62c4923f6528c977e55a2c4cfd0c1a4f6469c3d21ecdfb5158351806cc2431b059e1ef5f40d3f0cf58a70f7d13521867ca89ffc2089b1
6
+ metadata.gz: 69b1fddad703c3f2d8adc06ac44fb93f70cbe2e48273324d0519b99e9742737707714a50917f60669804610288477f163925bf47d1acbf0251b67d520c78319a
7
+ data.tar.gz: 2606853e62ddadc7eb1730846d31ade397090674702c4056472984e6028709385fe08c3b8aea8270ea1aa111b83f628bd06a43141c6349afc6b8405df7a87eb2
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'activerecord'
31
31
  spec.add_development_dependency 'sqlite3', '~> 1.4'
32
32
  spec.add_development_dependency 'yard', '~> 0.9.11'
33
- spec.add_development_dependency 'fast_jsonapi'
33
+ spec.add_development_dependency 'jsonapi_serializer'
34
34
  end
@@ -1,6 +1,6 @@
1
1
  require "dry_serialization/version"
2
2
  require "dry_serialization/blueprinter"
3
- require "dry_serialization/fast_jsonapi"
3
+ require "dry_serialization/jsonapi_serializer"
4
4
  require "dry_serialization/concerns/serialization_helper"
5
5
 
6
6
  module DrySerialization
@@ -7,9 +7,15 @@ module DrySerialization
7
7
 
8
8
  def error_response(errors, status = :unprocessable_entity)
9
9
  errors = [errors] unless errors.is_a?(Array)
10
- errors = { errors: errors }
10
+ errors = handle_errors(errors)
11
11
 
12
- render json: errors, status: status
12
+ render json: { errors: errors }, status: status
13
+ end
14
+
15
+ private
16
+
17
+ def handle_errors(errors)
18
+ errors.each_with_object([]) { |error, acc| acc << { detail: error } }
13
19
  end
14
20
 
15
21
  end
@@ -1,4 +1,4 @@
1
- module DrySerialization::FastJsonapi
1
+ module DrySerialization::JsonapiSerializer
2
2
 
3
3
  def serialized_resource(resource, serializer, options = {})
4
4
  if resource.is_a?(ActiveRecord::Relation) || resource.is_a?(Array)
@@ -1,3 +1,3 @@
1
1
  module DrySerialization
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.4"
3
3
  end
@@ -5,7 +5,7 @@ class BaseGenerator < Rails::Generators::Base
5
5
  SERIALIZERS = {
6
6
  ams: 'ActiveModelSerializers',
7
7
  blueprinter: 'Blueprinter',
8
- fast_jsonapi: 'FastJsonapi'
8
+ fast_jsonapi: 'JsonapiSerializer'
9
9
  }
10
10
 
11
11
  def self.exit_on_failure?
@@ -14,7 +14,7 @@ class BaseGenerator < Rails::Generators::Base
14
14
 
15
15
  private
16
16
 
17
- # Removes other serialization gems, currently just AMS and FastJsonapi
17
+ # Removes other serialization gems, currently just AMS and JsonapiSerializer
18
18
  def remove_other_supported_gems(*gems)
19
19
  gems = [gems] unless gems.is_a?(Array)
20
20
  return if gems.empty?
@@ -1,7 +1,7 @@
1
1
  require 'generators/base_generator'
2
2
 
3
3
  module DrySerialization
4
- module FastJsonapi
4
+ module JsonapiSerializer
5
5
  class InstallGenerator < BaseGenerator
6
6
  source_root File.expand_path("../../../templates", __FILE__)
7
7
 
@@ -9,13 +9,13 @@ module DrySerialization
9
9
  def install_blueprinter
10
10
  remove_other_supported_gems(SERIALIZERS[:blueprinter], SERIALIZERS[:ams])
11
11
 
12
- puts "Installing #{SERIALIZERS[:blueprinter]}..."
12
+ puts "Installing #{SERIALIZERS[:jsonapi_serializer]}..."
13
13
  insert_into_file('Gemfile',
14
- "\ngem 'fast_jsonapi'",
15
- after: "gem 'dry_serialization', source: 'https://gem.fury.io/mikeyduece-gems/'")
14
+ "\ngem 'jsonapi_serializer'",
15
+ after: "gem 'dry_serialization'")
16
16
  run 'bundle install'
17
17
 
18
- helper_include(SERIALIZERS[:fast_jsonapi])
18
+ helper_include(SERIALIZERS[:jsonapi_serializer])
19
19
  end
20
20
 
21
21
  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.2
4
+ version: 0.4.4
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-24 00:00:00.000000000 Z
11
+ date: 2020-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -137,7 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.9.11
139
139
  - !ruby/object:Gem::Dependency
140
- name: fast_jsonapi
140
+ name: jsonapi_serializer
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -163,11 +163,11 @@ files:
163
163
  - lib/dry_serialization.rb
164
164
  - lib/dry_serialization/blueprinter.rb
165
165
  - lib/dry_serialization/concerns/serialization_helper.rb
166
- - lib/dry_serialization/fast_jsonapi.rb
166
+ - lib/dry_serialization/jsonapi_serializer.rb
167
167
  - lib/dry_serialization/version.rb
168
168
  - lib/generators/base_generator.rb
169
169
  - lib/generators/dry_serialization/blueprinter/install_generator.rb
170
- - lib/generators/dry_serialization/fast_jsonapi/install_generator.rb
170
+ - lib/generators/dry_serialization/jsonapi_serializer/install_generator.rb
171
171
  - lib/generators/templates/api_controller.rb
172
172
  homepage:
173
173
  licenses: