Implement yaml_cast method