yes if you use convert_type(obj, Integer, to_int), it will call to_int if obj responds to it, and will raise a TypeError otherwise.