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

# UR::Object::Property(3pm)

Class representing metadata about a class property

## NAME

UR::Object::Property - Class representing metadata about a class property

## SYNOPSIS

```
  my $prop = UR::Object::Property->get(class_name => 'Some::Class', property_name => 'foo');
  my $class_meta = Some::Class->__meta__;
  my $prop2 = $class_meta->property_meta_for_name('foo');
  # Print out the meta-property name and its value of $prop2
  print map { " $_ : ".$prop2->$_ }
        qw(class_name property_name data_type default_value);
```

## DESCRIPTION

Instances of this class represent properties of classes.  For every item mentioned in the 'has' or 'id\_by' section of a class definition become Property objects.

## INHERITANCE

UR::Object::Property is a subclass of UR::Object

## PROPERTY TYPES

For this class definition:\
   class Some::Class {\
       has =\> \[\
           other\_id =\> { is =\> 'Text' },\
           other    =\> { is =\> 'Some::Other', id\_by =\> 'foo\_id' },\
           bar      =\> { via =\> 'other', to =\> 'bar' },\
           foos     =\> { is =\> 'Some::Foo', reverse\_as =\> 'some', is\_many =\> 1 },\
           uc\_other\_id =\> { calculate\_from =\> 'other\_id',\
                            calculate\_perl =\> 'uc($other\_id)' },\
       \],\
   };

Properties generally fall in to one of these categories:

- regular property

  A regular property of a class holds a single scalar.  In this case, 'other\_id' is a regular property.

- object accessor

  An object accessor property returns objects of some class.  The properties of this class must link in some way with all the ID properties of the remote class (the 'is' declaration).  'other' is an object accessor property.  This is how one-to-one relationships are implemented.

- via property

  When a class has some object accessor property, and it is helpful for an object to assume the value of the remote class's properties, you can set up a 'via' property.  In the example above, an object of this class  gets the value of its 'bar' property via the 'other' object it's linked to, from that object's 'bar' property.

- reverse as or is many property

  This is how one-to-many relationships are implemented.  In this case,  the Some::Foo class must have an object accessor property called 'some', and the 'foos' property will return a list of all the Some::Foo objects where their 'some' property would have returned that object.

- calculated property

  A calculated property doesn't store its data directly in the object, but  when its accessor is called, the calculation code is executed.

## PROPERTIES

Each property has a method of the same name

### Direct Properties

- class\_name =\> Text

  The name of the class this Property is attached to

- property\_name =\> Text

  The name of the property.  The pair of class\_name and property name are the ID properties of UR::Object::Property

- column\_name =\> Text

  If the class is backed by a database table, then the column this property's  data comes from is stored here

- data\_type =\> Text

  The type of data stored in this property.  Corresponds to the 'is' part of a class's property definition.

- data\_length =\> Number

  The maximum size of data stored in this property

- default\_value

  For is\_optional properties, the default value given when an object is created and this property is not assigned a value.

- valid\_values =\> ARRAY

  A listref of enumerated values this property may be set to

- doc =\> Text

  A place for documentation about this property

- is\_id =\> Boolean

  Indicates whether this is an ID property of the class

- is\_optional =\> Boolean

  Indicates whether this is property may have the value undef when the object is created

- is\_transient =\> Boolean

  Indicates whether this is property is transient?

- is\_constant =\> Boolean

  Indicates whether this property can be changed after the object is created.

- is\_mutable =\> Boolean

  Indicates this property can be changed via its accessor.  Properties cannot be both constant and mutable

- is\_volatile =\> Boolean

  Indicates this property can be changed by a mechanism other than its normal accessor method.  Signals are not emitted even when it does change via its normal accessor method.

- is\_classwide =\> Boolean

  Indicates this property's storage is shared among all instances of the class. When the value is changed for one instance, that change is effective for all instances.

- is\_delegated =\> Boolean

  Indicates that the value for this property is not stored in the object directly, but is delegated to another object or class.

- is\_calculated =\> Boolean

  Indicates that the value for this property is not a part of the object'd data directly, but is calculated in some way.

- is\_transactional =\> Boolean

  Indicates the changes to the value of this property is tracked by a Context's transaction and can be rolled back if necessary.

- is\_abstract =\> Boolean

  Indicates this property exists in a base class, but must be overridden in a derived class.

- is\_concrete =\> Boolean

  Antonym for is\_abstract.  Properties cannot be both is\_abstract and is\_concrete,

- is\_final =\> Boolean

  Indicates this property cannot be overridden in a derived class.

- is\_deprecated =\> Boolean

  Indicates this property's use is deprecated.  It has no effect in the use of the property in any way, but is useful in documentation.

- implied\_by =\> Text

  If this property is created as a result of another property's existence, implied\_by is the name of that other property.  This can happen in the case where an object accessor property is defined

  ```
    has => [
        foo => { is => 'Some::Other', id_by => 'foo_id' },
    ],
  ```

  Here, the 'foo' property requires another property called 'foo\_id', which is not explicitly declared.  In this case, the Property named foo\_id will have its implied\_by set to 'foo'.

- id\_by =\> ARRAY

  In the case of an object accessor property, this is the list of properties in this class that link to the ID properties in the remote class.

- reverse\_as =\> Text

  Defines the linking property name in the remote class in the case of an is\_many relationship

- via =\> Text

  For a via-type property, indicates which object accessor to go through.

- to =\> Text

  For a via-type property, indicates the property name in the remote class to get its value from.  The default value is the same as property\_name

- where =\> ARRAY

  Supplies additional filters for indirect properties.  For example:

  ```
    foos => { is => 'Some::Foo', reverse_as => 'some', is_many => 1 },
    blue_foos => { via => 'foos', where => [ color => 'blue' ] },
  ```

  Would create a property 'blue\_foos' which returns only the related Some::Foo objects that have 'blue' color.

- calculate\_from =\> ARRAY

  For calculated properties, this is a list of other property names the calculation is based on

- calculate\_perl =\> Text

  For calculated properties, a string containing Perl code.  Any properties mentioned in calculate\_from will exist in the code's scope at run time as scalars of the same name.

- class\_meta =\> UR::Object::Type

  Returns the class metaobject of the class this property belongs to

## METHODS

- via\_property\_meta

  For via/to delegated properties, return the property meta in the same class this property delegates through

- to\_property\_meta

  For via/to delegated properties, return the property meta on the foreign class that this property delegates to

## SEE ALSO

UR::Object::Type, UR::Object::Type::Initializer, UR::Object
