bright_serializer 0.4.0 → 0.4.1

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: 948f2e438a96ccd17416ace3e91375fae18b749795937f6db2494e3f3358ab8a
4
- data.tar.gz: 6541ab4c808bb8a872fcc02dfb8dc5747bda9a6344dc50594ad0dec5222ed676
3
+ metadata.gz: 840379a67e4354592d042785306facc35b8e663ed8cc27da09b9158b3d43fc6f
4
+ data.tar.gz: 817cf7a8dca2434c8e89cf3813678c1005086d9edb0fd11c76c4a3461470873f
5
5
  SHA512:
6
- metadata.gz: 90cb6ed0a7eb05ca181a52a4597693382b0976ecf5753f856fa0b81eadb71be3b4ac7e7da3a41df7a18b1ef884b42007dae9c0daf6711d73686ad6c5c230b962
7
- data.tar.gz: bf93c9d4b769e9f754b238d1efb297560647a1899679d2180af8ad16d0d554c80a124c056b9659481ecae6e326facf1922ccedff2dd5d7f5dd7d191c3828c8ed
6
+ metadata.gz: 1a598fcf576edf3395723c01dbaa7c00c45bc76ad2363599b9e16af0a7f4662a55007a6de49073cc2bb2bf36ceb63320c3fcfd58459147917b041deda1ae3204
7
+ data.tar.gz: 711ca41015c6fed810bd22ae1ce1914d87f9b40fdb33b084b891b4134ea5af1d291a1bce95e608f9f8cd3babf25440f1cce05433c6a8ddd935a4b2c43eebc907
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.4.1 (2022-04-10)
6
+
7
+ * Add deprecation warning for serialize nil object. See [issue #103](https://github.com/petalmd/bright_serializer/issues/103). ([v0.4.0...v0.4.1](https://github.com/petalmd/bright_serializer/compare/v0.4.0...v0.4.1))
8
+
5
9
  ## 0.4.0 (2022-11-10)
6
10
 
7
11
  * Added relation helper methods `has_one`, `has_many`, `belongs_to` ([#49](https://github.com/petalmd/bright_serializer/pull/49))
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bright_serializer (0.4.0)
4
+ bright_serializer (0.4.1)
5
+ activesupport (>= 5.2)
5
6
  oj (~> 3)
6
7
 
7
8
  GEM
@@ -86,7 +87,6 @@ PLATFORMS
86
87
  ruby
87
88
 
88
89
  DEPENDENCIES
89
- activesupport (~> 5.0)
90
90
  bright_serializer!
91
91
  bundler (~> 2)
92
92
  coveralls_reborn
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.require_paths = ['lib']
38
38
 
39
39
  spec.add_runtime_dependency 'oj', '~> 3'
40
- spec.add_development_dependency 'activesupport', '~> 5.0'
40
+ spec.add_dependency 'activesupport', '>= 5.2'
41
41
  spec.add_development_dependency 'bundler', '~> 2'
42
42
  spec.add_development_dependency 'faker', '~> 2'
43
43
  spec.add_development_dependency 'rake', '~> 13.0'
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'oj'
4
+ require 'active_support/deprecation'
4
5
  require_relative 'attribute'
5
6
  require_relative 'attribute_relation'
6
7
  require_relative 'inflector'
@@ -13,6 +14,11 @@ module BrightSerializer
13
14
 
14
15
  SUPPORTED_TRANSFORMATION = %i[camel camel_lower dash underscore].freeze
15
16
  DEFAULT_OJ_OPTIONS = { mode: :compat, time_format: :ruby, use_to_json: true }.freeze
17
+ DEPRECATION_MESSAGE = 'BrightSerializer: Serializing `nil` will stop returning ' \
18
+ "a JSON with all attributes and null values.\n" \
19
+ "To keep the old behaviour use an empty hash `MySerializer.new(object || { }).to_json`.\n" \
20
+ "See: https://github.com/petalmd/bright_serializer/issues/103 for more details about this change.\n"
21
+ private_constant :DEPRECATION_MESSAGE
16
22
 
17
23
  def self.included(base)
18
24
  super
@@ -27,6 +33,8 @@ module BrightSerializer
27
33
  end
28
34
 
29
35
  def serialize(object, attributes_to_serialize)
36
+ ActiveSupport::Deprecation.warn(DEPRECATION_MESSAGE) if object.nil?
37
+
30
38
  attributes_to_serialize.each_with_object({}) do |attribute, result|
31
39
  next unless attribute.condition?(object, @params)
32
40
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrightSerializer
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bright_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Francis Bastien
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-10 00:00:00.000000000 Z
11
+ date: 2023-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
34
- type: :development
33
+ version: '5.2'
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '5.0'
40
+ version: '5.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement