protobuf 2.3.1-java → 2.3.2-java

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.
@@ -159,7 +159,21 @@ module Protobuf
159
159
  def each_field
160
160
  all_fields.each do |field|
161
161
  value = __send__(field.name)
162
- yield(field, value)
162
+ yield(field, value)
163
+ end
164
+ end
165
+
166
+ def each_field_for_serialization
167
+ all_fields.each do |field|
168
+ next unless has_field?(field.name)
169
+
170
+ value = __send__(field.name)
171
+
172
+ if value.present? || [true, false].include?(value)
173
+ yield(field, value)
174
+ else
175
+ raise "#{field.name} is required on #{field.message_class}" if field.required?
176
+ end
163
177
  end
164
178
  end
165
179
 
@@ -14,9 +14,7 @@ module Protobuf
14
14
  raise NotInitializedError, "Message #{message.class.name} is not initialized (one or more fields is improperly set): #{JSON.parse(message.to_json)}"
15
15
  end
16
16
 
17
- message.each_field do |field, value|
18
- next unless message.has_field?(field.name)
19
-
17
+ message.each_field_for_serialization do |field, value|
20
18
  if field.repeated?
21
19
  if field.packed?
22
20
  key = (field.tag << 3) | WireType::LENGTH_DELIMITED
@@ -1,4 +1,4 @@
1
1
  module Protobuf
2
- VERSION = '2.3.1'
2
+ VERSION = '2.3.2'
3
3
  PROTOC_VERSION = '2.4.1'
4
4
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.3.1
5
+ version: 2.3.2
6
6
  platform: java
7
7
  authors:
8
8
  - BJ Neilsen