Comparison

plugins/mod_storage_xep0227.lua @ 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
parent 6700:0103dc8fa179
child 6702:6a5c6c95cf78
comparison
equal deleted inserted replaced
6700:0103dc8fa179 6701:88a25c364a14
148 }; 148 };
149 149
150 ----------------------------- 150 -----------------------------
151 local driver = {}; 151 local driver = {};
152 152
153 function driver:open(host, datastore, typ) 153 function driver:open(datastore, typ)
154 local instance = setmetatable({}, self);
155 instance.host = host;
156 instance.datastore = datastore;
157 local handler = handlers[datastore]; 154 local handler = handlers[datastore];
158 if not handler then return nil; end 155 if not handler then return nil, "unsupported-datastore"; end
159 for key,val in pairs(handler) do 156 local instance = setmetatable({ host = module.host; datastore = datastore; }, { __index = handler });
160 instance[key] = val;
161 end
162 if instance.init then instance:init(); end 157 if instance.init then instance:init(); end
163 return instance; 158 return instance;
164 end 159 end
165 160
166 module:provides("storage", driver); 161 module:provides("storage", driver);