General method for extracting the quantum efficiency of dispersive qubit readout in circuit QED