UR::Namespace(3pm)

πŸ“¦
version 0.470 Β· 2 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– UR::Namespace β€” manage collections of packages and classes πŸ’–

okay bestie, welcome to the UR::Namespace page from the User Contributed Perl Documentation, and let me tell you, this one is lowkey iconic. it's the vibe check for your whole class tree. let's get into it ✨


🌸 NAME 🌸

UR::Namespace β€” manage collections of packages and classes. that's it, that's the whole job, and it does it beautifully. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

so you're gonna make a file called MyApp.pm, and in it you write:

use UR;
UR::Object::Type->define(
    class_name => 'MyApp',
    is => 'UR::Namespace',
);

and then, like, every other program β€” plus all the modules chillin' in the MyApp subdirectory β€” can now just drop

use MyApp;

into their code, and boom πŸ’₯ they've got access to all the classes and all the data under the MyApp tree. it's giving main character energy fr fr.


✨ DESCRIPTION ✨

a UR namespace is the top-level object that represents your data's class structure in the most general way possible. it's the CEO of your package hierarchy. πŸ‘‘

so after you use a namespace module, your program gets access to the module autoloader, and the autoloader will automatically use modules on your behalf whenever you try to interact with their packages in a UR-y way β€” like calling get(), for example. it just knows. no cap. πŸͺ„

most programs will not interact with the Namespace at all, except to use its package. so if you're out here stressing about it, don't β€” you're fine, bestie. 🫢

🌈 Methods 🌈

πŸ’œ get_material_classes

my @class_metas = $namespace->get_material_classes();

returns a list of UR::Object::Type class metadata objects that exist in the given Namespace. okay so heads up: this uses File::Find to find *.pm files under the Namespace directory, and then it 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. like, we're not kidding. plan accordingly, okay? 😭

πŸŽ€ get_material_class_names

my @class_names = $namespace->get_material_class_names()

returns just the names of the classes produced by get_material_classes. the names only. no extras. minimal. clean. slay. ✨

πŸ“ get_data_sources

my @data_sources = $namespace->get_data_sources()

returns the data source objects it finds defined under the DataSource subdirectory of the namespace. that's the whole thing. simple, gorgeous, does what it says. πŸ’…

🧚 get_base_directory_name

my $path = $namespace->get_base_directory_name()

returns the directory path where the Namespace module was loaded from. so like, where it lives. its home. its little apartment. 🏠


πŸ‘‘ SEE ALSO πŸ‘‘

UR::Object::Type, UR::DataSource, UR::Context β€” go read those next bestie, they're all part of the same squad. 🫢


and that's the page!! written for perl v5.32.1, dated 2022-01-17, mwah πŸ’‹ thanks for reading, you ate this whole manpage, periodt. πŸ’–βœ¨

πŸ“¦ where this page comes from