NAME
UR::Object::Type - Class representing metadata about other classes
SYNOPSIS
use UR;
my $class_obj = UR::Object::Type->define(
class_name => 'MyClass',
is => ['ParentClass1', 'ParentClass2'],
id_by => ['id_prop1', 'id_prop2'],
has => [
id_prop1 => { is => 'Integer' },
id_prop2 => { is => 'String' },
property_a => { is => 'String' }
property_b => { is => Integer, is_optional => 1 },
],
);
my $obj1 = MyClass->get(id_prop1 => 5);
my $obj2 = MyClass->get(id_prop2 => 'Hello', property_a => 'There');
$class_obj = $obj1->__meta__;
$class_obj = MyClass->__meta__;
my @myclass_prop_names = $class_obj->direct_property_names;
my @all_prop_names = $class_obj->all_property_names;
my @property_metas = $class_obj->direct_property_metas;
my @parents = $class_obj->parent_class_names;
DESCRIPTION
UR::Object::Type implements the class behind the central metadata in the UR class framework. It contains methods for introspection and manipulation of related class data.
INHERITANCE
UR::Object::Type is a subclass of UR::Object
CONSTRUCTORS
- define
-
my $class_obj = UR::Object::Type->define( class_name => 'MyClass', ... );
Register a class with the system. The given class_name must be unique within the application. As a side effect, a new Perl namespace will be created for the class's name, and methods will be injected into that namespace for any of the class properties. Other types of metadata objects will get created to manage the properties and relationships to other classes. See the UR::Object::Type::Initializer documentation for more information about the parameters
define()
accepts. - create
-
my $class_obj = UR::Object::Type->create( class_name => 'Namespace::MyClass', ... );
Create a brand new class within an already existing UR namespace.
create()
takes all the same parameters asdefine()
. Another side effect of create is that when the application commits its Context, a new Perl module will be created to implement the class, complete with a class definition.Applications will not normally use create().
PROPERTIES
Each property has a method of the same name
Direct Properties
- class_name
-
$name = $class_obj->class_name
The name of the class. Class names are unique within a UR namespace and an application.
- doc
-
$doc = $class_obj->doc
A place to put general class-specific notes.
- data_source_id
-
$ds_id = $class_obj->data_source_id
The name of the external data source behind this class. Classes without data sources cannot be saved and exist only during the life of the application. data_source_id will resolve to an UR::DataSource id.
- table_name
-
$table_name = $class_object->table_name
For classes with data sources, this is the name of the table within that data source. This is usually a table in a relational database.
- is_abstract
-
$bool = $class_obj->is_abstract
A flag indicating if this is an abstract class. Abstract classes cannot have instances, but can be inherited by other classes.
- is_final
-
$bool = $class_obj->is_final
A flag indicating if this class cannot have subclasses.
- is_singleton
-
$bool = $class_obj->is_singleton
A flag indicating whether this is a singleton class. If true, the class will inherit from UR::Singleton.
- is_transactional
-
$bool = $class_obj->is_transactional
A flag indicating whether changes to this class's instances will be tracked.
Relation Properties
These methods return data about how this class relates to other classes.
- namespace
-
$namespace_name = $class_obj->namespace
Returns the name of the class's UR namespace.
- namespace_meta
-
$ns_meta = $class_obj->namespace_meta
Returns the UR::Namespace object with the class's namespace name.
- parent_class_names
-
@names = $class_obj->parent_class_names
Returns a list of the immediate parent classes.
- parent_class_metas
-
@class_objs = $class_obj->parent_class_metas
Returns a list of the class objects (UR::Object::Type instances) of the immediate parent classes
- ancestry_class_names
-
@names = $class_obj->ancestry_class_names
Returns a list of all the class names this class inherits from, directly or indirectly. This list may have duplicate names if there is multiple inheritance in the family tree.
- ancestry_class_metas
-
@class_objs = $class_obj->ancestry_class_metas
Returns a list of the class objects for each inherited class.
- direct_property_names
-
@names = $class_obj->direct_property_names
Returns a list of the property names defined within this class. This list will not include the names of any properties inherited from parent classes unless they have been overridden.
- direct_property_metas
-
@property_objs = $class_obj->direct_property_metas
Returns a list of the UR::Object::Property objects for each direct property name.
- ancestry_property_names
-
@names = $class_obj->ancestry_property_names
Returns a list of property names of the parent classes and their inheritance heirarchy. The list may include duplicates if a property is overridden somewhere in the heirarchy.
- ancestry_property_metas
-
@property_objs = $class_obj->ancestry_property_metas;
Returns a list of the UR::Object::Property objects for each ancestry property name.
- all_property_names
-
Returns a list of property names of the given class and its inheritance heirarchy. The list may include duplicates if a property is overridden somewhere in the heirarchy.
- all_property_metas
-
@property_objs = $class_obj->all_property_metas;
Returns a list of the UR::Object::Property objects for each name returned by all_property_names.
- direct_id_property_names
-
@names = $class_obj->direct_id_property_names
Returns a list of the property names designated as "id" properties in the class definition.
- direct_id_property_metas
-
@property_objs = $class_obj->direct_id_property_metas
Returns a list of the UR::Object::Property objects for each id property name.
- ancestry_id_property_names
- ancestry_id_property_metas
- all_id_property_names
- all_id_property_metas
-
@names = $class_obj->ancestry_id_property_names; @property_objs = $class_obj->ancestry_id_property_metas; @names = $class_obj->all_id_property_names; @property_objs = $class_obj->all_id_property_metas;
Returns the property names or UR::Object::Property objects for either the parent classes and their inheritance heirarchy, or for the given class and all of its inheritance heirarchy. The lists may include duplicates if properties are overridden somewhere in the heirarchy.
- direct_unique_metas
-
@unique_objs = $class_obj->direct_unique_metas
Returns a list of UR::Object::Property::Unique objects for the given class. Unique metadata objects are used to detail a class's unique constraints.
- direct_unique_property_names
- direct_unique_property_metas
- ancestry_unique_property_names
- ancestry_unique_property_metas
- all_unique_property_names
- all_unique_property_metas
-
@property_objs = $class_obj->direct_unique_property_metas; @names = $class_obj->all_unique_property_names;
Return lists of UR::Object::Property objects or their names for every property involved in the unique constraints on the class, or its inheritance heirarchy.
- ancestry_table_names
- all_table_names
-
@names = $class_obj->ancestry_table_names
Returns a list of table names in the class's inheritance heirarchy.
- direct_column_names
-
Returns a list of column names for each direct property meta. Classes with data sources and table names will have properties with column names.
- direct_id_column_names
-
Returns a list of ID column names for each direct property meta.
- direct_columnless_property_names
- direct_columnless_property_metas
- ancestry_columnless_property_names
- ancestry_columnless_property_metas
- all_columnless_property_names
- all_columnless_property_metas
-
Return lists of property meta objects and their names for properties that have no column name.
- reference_metas
-
@ref_objs = $class_obj->reference_metas
Returns a list of UR::Object::Reference objects for this class. Reference meta objects are how the system tracks class properties that return objects of another class.
- reference_property_metas
-
@ref_prop_objs = $class_obj->reference_property_metas
Returns a list of UR::Object::Reference::Property objects for this class. Reference Property meta objects are the details of how the properties of one class relate to the ID properties of anotehr class for properties that return objects of another class.
METHODS
- property_meta_for_name
-
$property_obj = $class_obj->property_meta_for_name($property_name);
Return the UR::Object::Property object in the class's inheritance hierarchy with the given name. If the property name has been overridden somewhere in the hierarchy, then it will return the property object most specific to the class.
- id_property_sorter
-
$subref = $class_obj->id_property_sorter; @sorted_objs = sort $subref @unsorted_objs;
Returns a subroutine reference that can be used to sort object instances of the class. The subref is able to handle classes with multiple ID properties, and mixes of numeric and non-numeric data and data types.
- autogenerate_new_object_id
-
This method is called whenever new objects of the given class are created through
ClassName->create()
, and not all of their ID properties were specified. UR::Object::Type has an implementation used by default, but other classes can override this if they need special handling.
5 POD Errors
The following errors were encountered while parsing the POD:
- Around line 87:
'=item' outside of any '=over'
- Around line 141:
You forgot a '=back' before '=head2'
- Around line 145:
'=item' outside of any '=over'
- Around line 334:
You forgot a '=back' before '=head1'
- Around line 336:
'=item' outside of any '=over'
=over without closing =back