protobuf 2.3.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/protobuf/message.rb +15 -1
- data/lib/protobuf/message/encoder.rb +1 -3
- data/lib/protobuf/version.rb +1 -1
- metadata +3 -3
data/lib/protobuf/message.rb
CHANGED
@@ -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.
|
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
|
data/lib/protobuf/version.rb
CHANGED
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.
|
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:
|
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:
|
513
|
+
hash: 2306560722844978679
|
514
514
|
requirements: []
|
515
515
|
rubyforge_project:
|
516
516
|
rubygems_version: 1.8.24
|