Add function to convert to bool.

Configurable function to convert an object or value to bool.