Sleep / hibernation logic on OS X I'm wondering what is a logic of sleep/hibernate of the OS X System. 

On the lid closing MacBook should go to sleep - it is obvious but.. What if the machine is running only on batteries and it is in sleep mode for a long time (until complete discharge of the bateries). Does OS X will store RAM on disk to keep user work safe?
It depends on how you have configured the hibernate bits in the power manager.

Setting aside desktop machines which by default to not write anything to persistent storage when the system enters sleep, the default behavior is to write a copy of RAM to storage so that either power remains to wake the machine from RAM or the system will detect the sleep image and restore from that rather than booting from a clean state.

You can set more exotic combinations using pmset and a shell, but it is not officially "supported".