Sour grapes: devaluing what you cannot reach
A fox who fails to reach a bunch of grapes walks away declaring they were probably sour anyway. The mechanism is self-protective revaluation: when a goal proves unattainable, the mind lowers its estimate of the goal's worth rather than admit its own failure. The disparagement tells you about the speaker's inability, not about the object.