core/actions.lua

changeset 2475
7ba448109537
parent 2474
d5ccf66dbf27
child 2476
586147e18fcc
equal deleted inserted replaced
2474:d5ccf66dbf27 2475:7ba448109537
1 -- Prosody IM
2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
4 --
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
8
9
10 local actions = {};
11
12 function register(path, t)
13 local curr = actions;
14 for comp in path:gmatch("([^/]+)/") do
15 if curr[comp] == nil then
16 curr[comp] = {};
17 end
18 curr = curr[comp];
19 if type(curr) ~= "table" then
20 return nil, "path-taken";
21 end
22 end
23 curr[path:match("/([^/]+)$")] = t;
24 return true;
25 end
26
27 return { actions = actions, register= register };

mercurial