aboutsummaryrefslogtreecommitdiffstats
path: root/util/filters.lua
diff options
context:
space:
mode:
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;
+};