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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39db10c77bd519fffda4b6e6c7e613bc1105a951ab39e677dd8d1aaa0aa6f6b0
4
- data.tar.gz: 5327aa7eb5e03f5abe504e4dde6d4e619df810af3802e896e28a72e9edc5c21f
3
+ metadata.gz: 3cb0544f358655737798992e56aca1d2b2637508bf05c1968788832028fe2048
4
+ data.tar.gz: e5ad28d55ce77894acbf6763553f478e257375d3f2cbb11e2c267d35e14d1841
5
5
  SHA512:
6
- metadata.gz: 1fcc67f9270e9c8359dc4488eaf11684fcb952f563a64d41f90cae3d83c1ff31a5c271c2247bc538fa3b5877241d3a7f769a32100c9e04ed9cb327caa15fa92f
7
- data.tar.gz: 982d8a1495d2c3a6eb83b498b79a6e9d40910f05226b3e4d14a0d5ab1100d04c4145c1d7e14ccd083f5329cf380089300e131848b7d9d2e6692f498793057b91
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
- res[@key] = @block ? @block.call(ser.object, opts) : ser.send(@key)
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
@@ -1,3 +1,3 @@
1
1
  module USerializer
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
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.2
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-25 00:00:00.000000000 Z
11
+ date: 2022-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler