The short answer is, no: There's no simple way to protect against this with certainty if you want to leave your bike unattended. The same thing can happen to a car: you return and the wheels are gone, the car up on cinder blocks.
Your question doesn't say where your bike was parked, but I'm guessing it was in a public area. It sounds to me like the thief knew what components they needed, and that they had the tools to get at them. There's really no way to protect against that, short of sealing your bike in a box.
You have a few options to discorage this: You can not leave the bike by itself, or you can park it in more secure areas.
I prefer parking my bike where I can keep an eye on it. If I'm stopping for lunch, I'll try to bring my bike into the restaurant with me. This is easier when I'm riding one of my folding bikes, and can slide it under a table or behind a chair. Some stores will even allow you to bring in a full-frame bike, especially if you're obviously being careful and polite.
If you have to leave your bike unattended regularly, such as at a train station or at an airport, look into renting a bike locker. If that's not an option and you have to lock your bike up "naked" in public, you can look into making your bike less attractive to thieves. (Spray-paint, duct tape, and so on can all serve well to this end.)