Support callable as 'serialize_when_undefined'