userializer 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/userializer/attribute.rb +6 -1
- data/lib/userializer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cb0544f358655737798992e56aca1d2b2637508bf05c1968788832028fe2048
|
4
|
+
data.tar.gz: e5ad28d55ce77894acbf6763553f478e257375d3f2cbb11e2c267d35e14d1841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59bcbc899d524be1e2804845cef37c3eddf446fdfb8f40c6d30ede4909561f5aadf2d9f7ad8b2564aa8e39d6bc79cf206c12966e020cca3528eb5e041fd2719b
|
7
|
+
data.tar.gz: 8a6e2acf4fb731529b867e0ef33f146a410662a0edd566c34a4a18edf08c67e822d9c2c0ac789cc657c3893bc906c90b974f78486ce4c91f4ae228e07b78c0a0
|
@@ -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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Montagne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|