Changeset

6701:88a25c364a14

mod_storage_xep0227: Update open method for current API
author Kim Alvefur <zash@zash.se>
date Fri, 15 May 2015 15:29:05 +0200
parents 6700:0103dc8fa179
children 6702:6a5c6c95cf78
files plugins/mod_storage_xep0227.lua
diffstat 1 files changed, 3 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_storage_xep0227.lua	Fri May 15 15:25:59 2015 +0200
+++ b/plugins/mod_storage_xep0227.lua	Fri May 15 15:29:05 2015 +0200
@@ -150,15 +150,10 @@
 -----------------------------
 local driver = {};
 
-function driver:open(host, datastore, typ)
-	local instance = setmetatable({}, self);
-	instance.host = host;
-	instance.datastore = datastore;
+function driver:open(datastore, typ)
 	local handler = handlers[datastore];
-	if not handler then return nil; end
-	for key,val in pairs(handler) do
-		instance[key] = val;
-	end
+	if not handler then return nil, "unsupported-datastore"; end
+	local instance = setmetatable({ host = module.host; datastore = datastore; }, { __index = handler });
 	if instance.init then instance:init(); end
 	return instance;
 end