serega 0.20.0 → 0.20.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11094f59dcd5d1d918604998ac267dbd13297bf0f70a9f3da5fd5ba74eb76b06
|
4
|
+
data.tar.gz: 97d1a419769b73937afde735e24210690e2f7702943d60db5be4252301e07255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9e3bfb207894f09c9c88658bad62e2a28e8b4d44648a74f807d332862b0cd7bdc67870f0d06786de0eb64537fd1a824c5d4f375406b71d18410b63c5a8c5320
|
7
|
+
data.tar.gz: 1171f2aabb7ce1c63a9e2f95f5413e9d80a882326ada4fac561b527c8a1adcc263ff19d6224eb070f0ebb333254ff48c9c7f56861ff6418732848cde3ffbc5b5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.20.
|
1
|
+
0.20.1
|
@@ -105,6 +105,11 @@ class Serega
|
|
105
105
|
serializer_class::SeregaAttribute.include(PluginsExtensions::Formatters::SeregaAttributeInstanceMethods)
|
106
106
|
end
|
107
107
|
|
108
|
+
if serializer_class.plugin_used?(:if)
|
109
|
+
require_relative "lib/plugins_extensions/if"
|
110
|
+
serializer_class::SeregaObjectSerializer.include(PluginsExtensions::If::ObjectSerializerInstanceMethods123)
|
111
|
+
end
|
112
|
+
|
108
113
|
if serializer_class.plugin_used?(:preloads)
|
109
114
|
require_relative "lib/plugins_extensions/preloads"
|
110
115
|
serializer_class::SeregaAttributeNormalizer.include(PluginsExtensions::Preloads::AttributeNormalizerInstanceMethods)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Serega
|
4
|
+
module SeregaPlugins
|
5
|
+
module Batch
|
6
|
+
#
|
7
|
+
# Extensions (mini-plugins) that are enabled when :batch plugin used with other plugins
|
8
|
+
#
|
9
|
+
module PluginsExtensions
|
10
|
+
#
|
11
|
+
# Extension that is used when :if plugin is loaded
|
12
|
+
#
|
13
|
+
module If
|
14
|
+
#
|
15
|
+
# SeregaObjectSerializer additional/patched class methods
|
16
|
+
#
|
17
|
+
# @see Serega::SeregaObjectSerializer
|
18
|
+
#
|
19
|
+
module ObjectSerializerInstanceMethods123
|
20
|
+
private
|
21
|
+
|
22
|
+
# Removes key added by `batch` plugin at the start of serialization to preserve attributes ordering
|
23
|
+
def attach_final_value(value, point, container)
|
24
|
+
container.delete(point.name) if super == SeregaPlugins::If::KEY_SKIPPED
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/serega/plugins/if/if.rb
CHANGED
@@ -42,11 +42,27 @@ class Serega
|
|
42
42
|
# end
|
43
43
|
#
|
44
44
|
module If
|
45
|
+
# This value must be returned to identify that serialization key was skipped
|
46
|
+
KEY_SKIPPED = :_key_skipped_with_serega_if_plugin
|
47
|
+
|
45
48
|
# @return [Symbol] Plugin name
|
46
49
|
def self.plugin_name
|
47
50
|
:if
|
48
51
|
end
|
49
52
|
|
53
|
+
# Checks requirements to load plugin
|
54
|
+
#
|
55
|
+
# @param serializer_class [Class<Serega>] Current serializer class
|
56
|
+
# @param opts [Hash] plugin options
|
57
|
+
#
|
58
|
+
# @return [void]
|
59
|
+
#
|
60
|
+
def self.before_load_plugin(serializer_class, **opts)
|
61
|
+
if serializer_class.plugin_used?(:batch)
|
62
|
+
raise SeregaError, "Plugin #{plugin_name.inspect} must be loaded before the :batch plugin"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
50
66
|
#
|
51
67
|
# Applies plugin code to specific serializer
|
52
68
|
#
|
@@ -194,12 +210,13 @@ class Serega
|
|
194
210
|
private
|
195
211
|
|
196
212
|
def serialize_point(object, point, _container)
|
197
|
-
return unless point.satisfy_if_conditions?(object, context)
|
213
|
+
return KEY_SKIPPED unless point.satisfy_if_conditions?(object, context)
|
198
214
|
super
|
199
215
|
end
|
200
216
|
|
201
217
|
def attach_final_value(value, point, _container)
|
202
|
-
return unless point.satisfy_if_value_conditions?(value, context)
|
218
|
+
return KEY_SKIPPED unless point.satisfy_if_value_conditions?(value, context)
|
219
|
+
|
203
220
|
super
|
204
221
|
end
|
205
222
|
end
|
@@ -88,6 +88,10 @@ class Serega
|
|
88
88
|
" - :auto_preload_attributes_with_serializer [Boolean] - Automatically adds `preload: <attribute_name>` option to attributes with :serializer option specified\n" \
|
89
89
|
" - :auto_hide_attributes_with_preload [Boolean] - Automatically adds `hide: true` option to attributes with :preload option (specified manually or added automatically)"
|
90
90
|
end
|
91
|
+
|
92
|
+
if serializer_class.plugin_used?(:batch)
|
93
|
+
raise SeregaError, "Plugin #{plugin_name.inspect} must be loaded before the :batch plugin"
|
94
|
+
end
|
91
95
|
end
|
92
96
|
|
93
97
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serega
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Glushkov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
JSON Serializer
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/serega/plugins/batch/lib/modules/plan_point.rb
|
55
55
|
- lib/serega/plugins/batch/lib/plugins_extensions/activerecord_preloads.rb
|
56
56
|
- lib/serega/plugins/batch/lib/plugins_extensions/formatters.rb
|
57
|
+
- lib/serega/plugins/batch/lib/plugins_extensions/if.rb
|
57
58
|
- lib/serega/plugins/batch/lib/plugins_extensions/preloads.rb
|
58
59
|
- lib/serega/plugins/batch/lib/validations/check_batch_opt_id_method.rb
|
59
60
|
- lib/serega/plugins/batch/lib/validations/check_batch_opt_loader.rb
|
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
141
|
- !ruby/object:Gem::Version
|
141
142
|
version: '0'
|
142
143
|
requirements: []
|
143
|
-
rubygems_version: 3.5.
|
144
|
+
rubygems_version: 3.5.6
|
144
145
|
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: JSON Serializer
|