I have been plagued with every pest imaginable, but been spared rats so far. Phew! Usually they love places where they can get stuff like animal feed (as in barns) or birdseed and so forth. Sounds like whether you compost or not, you need to tackle the rats by your greenhouse, and reduce the population and stay on top of it. I am currently on a major mole-trapping campaign (using mousetraps) outdoors and in my basement; ditto with mice. Nasty, but necessary. As for composting and rats, I guess you mean you’re worried about composting your food scraps; yard waste should be fine, and are more likely to invite nesting than eating by rats. To make the pile an unattractive nest, moisten it regularly so it’s damp (but not sodden). Dry ingredients don’t break down, anyhow, so moistening is good for the composting process as well and damp piles are inhospitable to nesting rats. Yard waste is where most of the compost resources come from anyway; food scraps are a minority. Food scraps could be composted in an enclosed device such as a tumbler or bin, or in a hardware-cloth pen, or even easier make them unpalatable or inaccessible by burying them in the heap or ground, or sprinkling each layer of food scraps with a shovel of soil, which actually inoculates the compost with good organisms anyway. Again, Step 1: Get rid of the rats.