diff options
author | Peter Kozak <spag@golwen.net> | 2013-07-24 09:41:09 +0200 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-07-24 09:41:09 +0200 |
commit | f8b94f329a89fe06428bcf417b2ad7e09b1f95c6 (patch) | |
tree | 3ff3b54e0fe8db2bd0840d0c0e9cc2641aa30c7d /misc/freeswitch/scripts/common | |
parent | 7ba230f29cd40c699be93063a88f65c703549ada (diff) |
load_one method added
Diffstat (limited to 'misc/freeswitch/scripts/common')
-rw-r--r-- | misc/freeswitch/scripts/common/object.lua | 13 |
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 |