For something like this, (and to make it easily accessible to whomever, even remotely) you could use a script (using grep/awk/etc.) that checks the output from 'df'. If there is an entry for /dev/cdrom (or whatever you cdrom is), then eject. If there isn't, there isn't likely to be a disk in the drive. This is simple, but has a flaw. If your drive is a cdrw, it won't eject if there's a blank disk in the drive. To overcome this flaw, you need to know a little more about how cd drives work, and then it becomes one of those "if you know this much, you wouldn't be posting this question" kind of things. Then again, you won't typically need a supermount function for a blank disk.
For the simple version, just grep 'df' for '/dev/cdrom' or whatever your device is, and place the result into a variable. Test it to see if it's 'true' or not. If you get no result (no /dev/cdrom in df list), it will be false, any mounted cdrom will return true.
One caveat: Some oddball scripting languages invert true and false (t=0/null, false=anything else). If you're using one of them, you probably already know this, though.