diff options
author | Kim Alvefur <zash@zash.se> | 2016-11-28 07:30:21 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-11-28 07:30:21 +0100 |
commit | 06124bad4d8c84f2d18e64a55eef0a8bfa55e7eb (patch) | |
tree | f9e780bc98d11d5fd75dd7a6c1c779301d17ad09 /util/stanza.lua | |
parent | 8f3f909b30079072560fb3cb1b21c95c2845cce9 (diff) | |
download | prosody-06124bad4d8c84f2d18e64a55eef0a8bfa55e7eb.tar.gz prosody-06124bad4d8c84f2d18e64a55eef0a8bfa55e7eb.zip |
util.stanza: Add an is_stanza() function to check if an object is a stanza
Diffstat (limited to 'util/stanza.lua')
-rw-r--r-- | util/stanza.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/util/stanza.lua b/util/stanza.lua index 8bb9ba05..2191fa8e 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -14,6 +14,7 @@ local s_format = string.format; local s_match = string.match; local tostring = tostring; local setmetatable = setmetatable; +local getmetatable = getmetatable; local pairs = pairs; local ipairs = ipairs; local type = type; @@ -45,6 +46,10 @@ local function new_stanza(name, attr) return setmetatable(stanza, stanza_mt); end +local function is_stanza(s) + return getmetatable(s) == stanza_mt; +end + function stanza_mt:query(xmlns) return self:tag("query", { xmlns = xmlns }); end @@ -417,6 +422,7 @@ end return { stanza_mt = stanza_mt; stanza = new_stanza; + is_stanza = is_stanza; new_id = new_id; preserialize = preserialize; deserialize = deserialize; |