diff options
author | Kim Alvefur <zash@zash.se> | 2015-02-21 10:36:37 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2015-02-21 10:36:37 +0100 |
commit | 3015aac8bcb38ed2d00b8f5205bd54d82b96e71a (patch) | |
tree | f7609b77dfead0a8d6994597c5799196676080bd /util/filters.lua | |
parent | 2b0b78b8b0210906d14f52f70fffefac2a744dba (diff) | |
download | prosody-3015aac8bcb38ed2d00b8f5205bd54d82b96e71a.tar.gz prosody-3015aac8bcb38ed2d00b8f5205bd54d82b96e71a.zip |
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Diffstat (limited to 'util/filters.lua')
-rw-r--r-- | util/filters.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/util/filters.lua b/util/filters.lua index 427dcb7c..f405c0bd 100644 --- a/util/filters.lua +++ b/util/filters.lua @@ -8,11 +8,11 @@ local t_insert, t_remove = table.insert, table.remove; -module "filters" +local _ENV = nil; local new_filter_hooks = {}; -function initialize(session) +local function initialize(session) if not session.filters then local filters = {}; session.filters = filters; @@ -36,7 +36,7 @@ function initialize(session) return session.filter; end -function add_filter(session, type, callback, priority) +local function add_filter(session, type, callback, priority) if not session.filters then initialize(session); end @@ -60,7 +60,7 @@ function add_filter(session, type, callback, priority) filter_list[callback] = priority; end -function remove_filter(session, type, callback) +local function remove_filter(session, type, callback) if not session.filters then return; end local filter_list = session.filters[type]; if filter_list and filter_list[callback] then @@ -74,11 +74,11 @@ function remove_filter(session, type, callback) end end -function add_filter_hook(callback) +local function add_filter_hook(callback) t_insert(new_filter_hooks, callback); end -function remove_filter_hook(callback) +local function remove_filter_hook(callback) for i=1,#new_filter_hooks do if new_filter_hooks[i] == callback then t_remove(new_filter_hooks, i); @@ -86,4 +86,10 @@ function remove_filter_hook(callback) end end -return _M; +return { + initialize = initialize; + add_filter = add_filter; + remove_filter = remove_filter; + add_filter_hook = add_filter_hook; + remove_filter_hook = remove_filter_hook; +}; |