From f8b94f329a89fe06428bcf417b2ad7e09b1f95c6 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 24 Jul 2013 09:41:09 +0200 Subject: load_one method added --- misc/freeswitch/scripts/common/object.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'misc') 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 -- cgit v1.2.3