Class: ProtocolBuffers::Field::MessageField
Instance Attribute Summary
#name, #otype, #tag
Instance Method Summary
collapse
#wire_type
#add_methods_to, #check_valid, #check_value, create, #inspect_value, #repeated?
Constructor Details
#initialize(proxy_class, otype, name, tag, opts = {}) ⇒ MessageField
524
525
526
527
|
# File 'lib/protocol_buffers/runtime/field.rb', line 524
def initialize(proxy_class, otype, name, tag, opts = {})
super(otype, name, tag, opts)
@proxy_class = proxy_class
end
|
Instance Method Details
#default_value ⇒ Object
529
530
531
|
# File 'lib/protocol_buffers/runtime/field.rb', line 529
def default_value
@proxy_class.new
end
|
#deserialize(io) ⇒ Object
544
545
546
|
# File 'lib/protocol_buffers/runtime/field.rb', line 544
def deserialize(io)
@proxy_class.parse(io)
end
|
#serialize(value) ⇒ Object
TODO: serialize could be more efficient if it used the underlying stream
directly rather than string copying, but that would require knowing the
length beforehand.
540
541
542
|
# File 'lib/protocol_buffers/runtime/field.rb', line 540
def serialize(value)
value.to_s
end
|
#valid_type?(value) ⇒ Boolean
533
534
535
|
# File 'lib/protocol_buffers/runtime/field.rb', line 533
def valid_type?(value)
value.is_a?(@proxy_class)
end
|