protobuf 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -501,7 +501,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
501
501
  version: '0'
502
502
  segments:
503
503
  - 0
504
- hash: -2545175995844077930
504
+ hash: 2306560722844978679
505
505
  required_rubygems_version: !ruby/object:Gem::Requirement
506
506
  none: false
507
507
  requirements:
@@ -510,7 +510,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
510
510
  version: '0'
511
511
  segments:
512
512
  - 0
513
- hash: -2545175995844077930
513
+ hash: 2306560722844978679
514
514
  requirements: []
515
515
  rubyforge_project:
516
516
  rubygems_version: 1.8.24