This just happened to me. I was flying Premium Economy on BA from LHR to JFK. I got upgraded at the gate to Club World even though I am only Bronze on BA but Sapphire on OneWorld through AA platinum.
My Boss was flying LHR to DEN and he's BA Gold and had done 7 round trips to Delhi via London in the last 15 months so he's got way more history with BA but he didn't get upgraded.
We were told that you are more likely to get upgraded a level if the plane is busy in coach and busy in Premium as they can accommodate more paying standby customers by moving higher status passengers up a class. Having said that, my flight was 30% empty in Premium and 50% empty in Club World so I don't really know what triggers these things