userializer 0.3.2 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/userializer/array_serializer.rb +1 -1
- data/lib/userializer/attribute.rb +6 -1
- data/lib/userializer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6aa1e23fadfa753380b8295f2438939b47b691be108b8f9e8307d43bce6066ad
|
4
|
+
data.tar.gz: 53641e65a503ca7145e9d1dd7bd98483589668696c11d098f3061b9d018f07ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa343936b8c54a8c293d2e4952f84b92629b4ed99d2bd32c2559a66718b1592c7d7c1a20b53474e684691bd31a1214c631853422ea42a809b988c239d431268d
|
7
|
+
data.tar.gz: 5f47fbf1ec13d6a3155741d73d2b007c3572ce47279386e946b07cca723b0643e37f0ad7daf3c4efd151b2e1aa1ba318b5f4f25e4168f66d51f08f0763c842d4
|
@@ -14,7 +14,7 @@ module USerializer
|
|
14
14
|
|
15
15
|
raise HeterogeneousArray if clss.count > 1
|
16
16
|
|
17
|
-
@root_key = opts[:root]
|
17
|
+
@root_key = opts[:root]&.to_sym
|
18
18
|
@root_key ||= ActiveSupport::Inflector.pluralize(
|
19
19
|
ActiveSupport::Inflector.underscore(obj_class.name).split('/').last
|
20
20
|
).to_sym if obj_class
|
@@ -7,13 +7,18 @@ module USerializer
|
|
7
7
|
@opts = opts
|
8
8
|
@block = block
|
9
9
|
|
10
|
+
@skip_nil = opts[:skip_nil] || false
|
10
11
|
@conditional_block = opts[:if] || proc { true }
|
11
12
|
end
|
12
13
|
|
13
14
|
def merge_attributes(res, ser, opts)
|
14
15
|
return unless @conditional_block.call(ser.object, opts)
|
15
16
|
|
16
|
-
|
17
|
+
value = @block ? @block.call(ser.object, opts) : ser.send(@key)
|
18
|
+
|
19
|
+
return if value.nil? && @skip_nil
|
20
|
+
|
21
|
+
res[@key] = value
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
data/lib/userializer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: userializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Montagne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
rubygems_version: 3.
|
127
|
+
rubygems_version: 3.2.32
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Write a short summary, because RubyGems requires one.
|