util.stanza: stanza:reset() method to reset building state
authorMatthew Wild <mwild1@gmail.com>
Wed, 8 Apr 2009 19:12:40 +0000 (20:12 +0100)
committerMatthew Wild <mwild1@gmail.com>
Wed, 8 Apr 2009 19:12:40 +0000 (20:12 +0100)
util/stanza.lua

index 1ad3679ba84579bc92122d18146272bdc9730ad7..7e40dfa43d1dadb14e4fa0e24ab88dd12d805f75 100644 (file)
@@ -65,6 +65,14 @@ function stanza_mt:up()
        return self;
 end
 
+function stanza_mt:reset()
+       local last_add = self.last_add;
+       for i = 1,#last_add do
+               last_add[i] = nil;
+       end
+       return self;
+end
+
 function stanza_mt:add_direct_child(child)
        if type(child) == "table" then
                t_insert(self.tags, child);