Limit shipping module to certain product category

What would be the correct approach to limit a shipping option (module) to certain categories? 

Let's say we have a module based on the default zone/weight based shipping module, but we want to limit it to 2 or 3 categories, what would be the right approach? Even if it would be hardcoded. 

Basically I want a shipping option, and that if products outside of 1 or 2 categories are added to the order, that this shipping option should become unavailable. In example, an order with items with categories 1 and 2 can have this option, but if the order has an item from category 3, the option should become unavailable.

I could use a little bit of a direction here, and patch up the aesthetics later on. :)