Compositor and show / hide object in rendering

is there a way to switch an object on off for the compositor automatically when rendering render passes?

obviously you can do it by hand but can you automate this?