protobuf 2.4.0-java → 2.4.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/protobuf/message.rb +16 -12
- data/lib/protobuf/version.rb +1 -1
- metadata +1 -1
data/lib/protobuf/message.rb
CHANGED
@@ -160,16 +160,24 @@ module Protobuf
|
|
160
160
|
|
161
161
|
def each_field_for_serialization
|
162
162
|
all_fields.each do |field|
|
163
|
-
next unless
|
163
|
+
next unless has_field?(field.name) || field.required?
|
164
164
|
|
165
|
-
value =
|
166
|
-
value.compact! if field.repeated?
|
165
|
+
value = @values[field.name]
|
167
166
|
|
168
|
-
if
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
167
|
+
if field.repeated?
|
168
|
+
if !value.nil?
|
169
|
+
value.compact!
|
170
|
+
@values[field.name] = nil if value.empty?
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
if has_field?(field.name) || field.required?
|
175
|
+
if value.present? || [true, false].include?(value)
|
176
|
+
yield(field, value)
|
177
|
+
else
|
178
|
+
# Only way you can get here is if you are required and not present
|
179
|
+
raise ::Protobuf::SerializationError, "#{field.name} is required on #{field.message_class}"
|
180
|
+
end
|
173
181
|
end
|
174
182
|
end
|
175
183
|
end
|
@@ -339,10 +347,6 @@ module Protobuf
|
|
339
347
|
object
|
340
348
|
end
|
341
349
|
|
342
|
-
def has_field_or_required_field?(field)
|
343
|
-
has_field?(field.name) || field.required?
|
344
|
-
end
|
345
|
-
|
346
350
|
# Encode key and value, and write to +stream+.
|
347
351
|
def write_pair(stream, field, value)
|
348
352
|
key = (field.tag << 3) | field.wire_type
|
data/lib/protobuf/version.rb
CHANGED