From c0e0377e384c8167172ee06d8c11ef2f782522c7 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 17 Oct 2013 18:59:27 +0000 Subject: Remove all calls to 'module' in preparation for move to Lua 5.2 Use mymodule parameter for module definition. This was also helpfule in revealing places where the code relied on the global environment. --- lib/authenticator-plaintext.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib/authenticator-plaintext.lua') diff --git a/lib/authenticator-plaintext.lua b/lib/authenticator-plaintext.lua index caa6748..ecfca03 100644 --- a/lib/authenticator-plaintext.lua +++ b/lib/authenticator-plaintext.lua @@ -7,12 +7,12 @@ create a different file for each field. ]]-- -module (..., package.seeall) +local mymodule = {} fs = require("acf.fs") posix = require("posix") -list_fields = function(self, tabl) +mymodule.list_fields = function(self, tabl) if not self or not tabl or tabl == "" then return {} end @@ -27,7 +27,7 @@ list_fields = function(self, tabl) return fields end -read_field = function(self, tabl, field) +mymodule.read_field = function(self, tabl, field) if not self or not tabl or tabl == "" or not field then return nil end @@ -53,7 +53,7 @@ read_field = function(self, tabl, field) end end -delete_field = function(self, tabl, field) +mymodule.delete_field = function(self, tabl, field) if not self or not tabl or tabl == "" or not field then return false end @@ -62,7 +62,7 @@ delete_field = function(self, tabl, field) return true end -write_entry = function(self, tabl, field, id, entry) +mymodule.write_entry = function(self, tabl, field, id, entry) if not self or not tabl or tabl == "" or not field or not id or not entry then return false end @@ -83,7 +83,7 @@ write_entry = function(self, tabl, field, id, entry) return true end -read_entry = function(self, tabl, field, id) +mymodule.read_entry = function(self, tabl, field, id) if not self or not tabl or tabl == "" or not field or not id then return nil end @@ -99,7 +99,7 @@ read_entry = function(self, tabl, field, id) return nil end -delete_entry = function (self, tabl, field, id) +mymodule.delete_entry = function (self, tabl, field, id) if not self or not tabl or tabl == "" or not field or not id then return false end @@ -123,11 +123,13 @@ delete_entry = function (self, tabl, field, id) -- If deleting the main field, delete all other fields also if field == "" then - local fields = list_fields(self, tabl) + local fields = mymodule.list_fields(self, tabl) for i,fld in ipairs(fields) do - delete_entry(self, tabl, fld, id) + mymodule.delete_entry(self, tabl, fld, id) end end return result end + +return mymodule -- cgit v1.2.3