Add a class to manage the lifetime of Lua refs automatically.