---
name: "UR::Namespace"
section: "3pm"
platform: "linux"
package: "libur-perl"
version: "0.470+ds-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/UR::Namespace"
---

# UR::Namespace(3pm)

Manage collections of packages and classes

## NAME

UR::Namespace - Manage collections of packages and classes

## SYNOPSIS

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.

## DESCRIPTION

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.

## Methods

- get\_material\_classes

  ```
    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.

- get\_material\_class\_names

  ```
    my @class_names = $namespace->get_material_class_names()
  ```

  Return just the names of the classes produced by `"get_material_classes"`.

- get\_data\_sources

  ```
    my @data_sources = $namespace->get_data_sources()
  ```

  Return the data source objects it finds defined under the DataSource subdirectory of the namespace.

- get\_base\_directory\_name

  ```
    my $path = $namespace->get_base_directory_name()
  ```

  Returns the directory path where the Namespace module was loaded from.

## SEE ALSO

UR::Object::Type, UR::DataSource, UR::Context
