UR::Namespace(3pm) | User Contributed Perl Documentation | UR::Namespace(3pm) |
UR::Namespace - Manage collections of packages and classes
In a file called MyApp.pm:
use UR; UR::Object::Type->define( class_name => 'MyApp', is => 'UR::Namespace', );
Other programs, as well as modules in the MyApp subdirectory can now put
use MyApp;
in their code, and they will have access to all the classes and data under the MyApp tree.
A UR namespace is the top-level object that represents your data's class structure in the most general way. After use-ing a namespace module, the program gets access to the module autoloader, which will automatically use modules on your behalf if you attempt to interact with their packages in a UR-y way, such as calling get().
Most programs will not interact with the Namespace, except to "use" its package.
my @class_metas = $namespace->get_material_classes();
Return a list of UR::Object::Type class metadata object that exist in the given Namespace. Note that this uses File::Find to find "*.pm" files under the Namespace directory and calls "UR::Object::Type->get($name)" for each package name to get the autoloader to use the package. It's likely to be pretty slow.
my @class_names = $namespace->get_material_class_names()
Return just the names of the classes produced by "get_material_classes".
my @data_sources = $namespace->get_data_sources()
Return the data source objects it finds defined under the DataSource subdirectory of the namespace.
my $path = $namespace->get_base_directory_name()
Returns the directory path where the Namespace module was loaded from.
UR::Object::Type, UR::DataSource, UR::Context
2022-01-17 | perl v5.32.1 |