summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-07-24 09:41:09 +0200
committerPeter Kozak <spag@golwen.net>2013-07-24 09:41:09 +0200
commitf8b94f329a89fe06428bcf417b2ad7e09b1f95c6 (patch)
tree3ff3b54e0fe8db2bd0840d0c0e9cc2641aa30c7d /misc
parent7ba230f29cd40c699be93063a88f65c703549ada (diff)
load_one method added
Diffstat (limited to 'misc')
-rw-r--r--misc/freeswitch/scripts/common/object.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/common/object.lua b/misc/freeswitch/scripts/common/object.lua
index 68e1361..5482168 100644
--- a/misc/freeswitch/scripts/common/object.lua
+++ b/misc/freeswitch/scripts/common/object.lua
@@ -116,3 +116,16 @@ function Object.find(self, attributes)
return object;
end
+
+-- local class from module
+function Object.load_one(self, module_path)
+ result, module_data = pcall(require, module_path);
+ if not result or not module_data then
+ return nil, module_data;
+ end
+ for object_name in pairs(module_data) do
+ if tostring(object_name[1]) ~= '_' then
+ return module_data[object_name];
+ end
+ end
+end