aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_internal.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-03-31 17:34:33 +0200
committerKim Alvefur <zash@zash.se>2017-03-31 17:34:33 +0200
commit0ca328a00c3ab900d996c33755ef73ca869d153d (patch)
tree3c602d0dd6825aa7b5dd1c19454bca8ef617cc20 /plugins/mod_storage_internal.lua
parent72018f7be717db4e99cf175d46cbc9d97c6249aa (diff)
downloadprosody-0ca328a00c3ab900d996c33755ef73ca869d153d.tar.gz
prosody-0ca328a00c3ab900d996c33755ef73ca869d153d.zip
mod_storage_internal: Separate driver from keyval implementation
Diffstat (limited to 'plugins/mod_storage_internal.lua')
-rw-r--r--plugins/mod_storage_internal.lua16
1 files changed, 10 insertions, 6 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua
index ade4f0a6..dd8cf61f 100644
--- a/plugins/mod_storage_internal.lua
+++ b/plugins/mod_storage_internal.lua
@@ -3,19 +3,23 @@ local datamanager = require "core.storagemanager".olddm;
local host = module.host;
local driver = {};
-local driver_mt = { __index = driver };
function driver:open(store, typ)
- if typ and typ ~= "keyval" then
+ local mt = self[typ or "keyval"]
+ if not mt then
return nil, "unsupported-store";
end
- return setmetatable({ store = store, type = typ }, driver_mt);
+ return setmetatable({ store = store, type = typ }, mt);
end
-function driver:get(user)
+
+local keyval = { };
+driver.keyval = { __index = keyval };
+
+function keyval:get(user)
return datamanager.load(user, host, self.store);
end
-function driver:set(user, data)
+function keyval:set(user, data)
return datamanager.store(user, host, self.store, data);
end
@@ -23,7 +27,7 @@ function driver:stores(username)
return datamanager.stores(username, host);
end
-function driver:users()
+function keyval:users()
return datamanager.users(host, self.store, self.type);
end