class Protobuf::Field::BaseField

def set(message_instance, bytes)

Decode +bytes+ and pass to +message_instance+.
def set(message_instance, bytes)
  if packed?
    array = message_instance.__send__(getter_method_name)
    method = \
      case wire_type
      when WireType::FIXED32 then :read_fixed32
      when WireType::FIXED64 then :read_fixed64
      when WireType::VARINT  then :read_varint
      end
    stream = StringIO.new(bytes)
    until stream.eof?
      array << decode(Decoder.__send__(method, stream))
    end
  else
    value = decode(bytes)
    if repeated?
      message_instance.__send__(getter_method_name) << value
    else
      message_instance.__send__(setter_method_name, value)
    end
  end
end