protip 0.37 → 0.37.2

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: b91d785c337df88feedaf062679787c1745e8e7ee420535549ccbd6e5f61fab1
4
- data.tar.gz: e897d6cda03fe31835f9a8e2243be0cb7f0875adbf590a05154d169e6252924b
3
+ metadata.gz: 236eb63af48bf81e28875f5dcdef16158ba69db7785436f47013481bab29fd51
4
+ data.tar.gz: 948cede4acce33d7da2e13af36da7f51d35cd073327ca6d666759004afd15140
5
5
  SHA512:
6
- metadata.gz: 84d548ff44b595968e6c05e7a794e2aca2bb9e51f4f3068615034de13bb2f2a02a0d94f3cfa1490c99b1856c5fc5c2c66661793b989c9f3430a891a445ad3a24
7
- data.tar.gz: d5e34084b562c4a3b424a94d1fe2a46926fd14a3c0e3da6b9f5bc0d335af24d824a0cbc0be3c30b8eedbcaba316b374d6372bd1caeb83a94290c540cc5f5b200
6
+ metadata.gz: 833843e0287ad841903526db31eb40daef4dfaa389b23ab7dd34643bdc508c5696ee2f58f8a2a51697558008f1205e0a0180361129a090f6adf34d7d54a14787
7
+ data.tar.gz: b799bb1e32e81541ffe1a90e3a64721df338ee5fe8e315bfbab83486e4e1212866705af804bfd55308d0f39a9e11d07e54fd0613c9de1dc933e34bbb82463196
@@ -228,9 +228,14 @@ module Protip
228
228
  def set(field, value)
229
229
  return if field.label == :optional && value.nil? && get(field).nil?
230
230
 
231
- return message[field.name].replace value.map{|v| to_protobuf_value field, v} if field.label == :repeated
231
+ if field.label == :repeated
232
+ new_values = value.map {|v| to_protobuf_value(field, v) }.compact
233
+
234
+ message[field.name].replace(new_values)
235
+ else
236
+ message[field.name] = to_protobuf_value(field, value)
237
+ end
232
238
 
233
- message[field.name] = to_protobuf_value(field, value)
234
239
  end
235
240
 
236
241
  # Helper for setting values - converts the value for the given
@@ -238,7 +243,7 @@ module Protip
238
243
  def to_protobuf_value(field, value)
239
244
  if field.type == :message
240
245
  if nil == value
241
- nil
246
+ field&.default || field&.subtype&.msgclass&.new
242
247
  # This check must happen before the nested_resources check to
243
248
  # ensure nested messages are set properly
244
249
  elsif value.is_a?(field.subtype.msgclass)
@@ -1,3 +1,3 @@
1
1
  module Protip
2
- VERSION = '0.37'
2
+ VERSION = '0.37.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protip
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.37'
4
+ version: 0.37.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - AngelList
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-10 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel