aboutsummaryrefslogtreecommitdiffstats
path: root/util/filters.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-02-21 10:36:37 +0100
committerKim Alvefur <zash@zash.se>2015-02-21 10:36:37 +0100
commiteaa823a5971bfd2e9cb38dd8f30fefee2da95c2e (patch)
treef7609b77dfead0a8d6994597c5799196676080bd /util/filters.lua
parentb49513cdeb2bb123625fb87f53a04d42b7eb6fb2 (diff)
downloadprosody-eaa823a5971bfd2e9cb38dd8f30fefee2da95c2e.tar.gz
prosody-eaa823a5971bfd2e9cb38dd8f30fefee2da95c2e.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.lua20
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;
+};