How to make mask only for one object without render layers?

Hi everybody, I have a little problem. I need to make a mask only for one object and see another through mask. I made it with render layers, but its solution for many objects.

I want to make it more simple. Let say Cube1 is object and Cube2 is mask. And only Cube1 is included for masking. I understand its need some scipting, but does it hard to make some extra checkpoints or buttons to make include/exclude? Can anyone help with this question or maybe know some plugin or know how to make a script?:spin: