UR::Ob...operty(3pm)
β¨ NAME β¨
UR::Object::Property β bestie, this is the class that represents metadata about a class property. it's the little info-card behind every property your class has π
π SYNOPSIS π
okay so here's how you actually touch one:
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);
like, grab the meta, ask it about a property, print the juicy bits. slay π
π¦ DESCRIPTION π¦
so, instances of this class represent properties of classes. every single item you mention in the has or id_by section of a class definition? yeah, each one becomes a Property object. no cap. π«Ά
πΈ INHERITANCE πΈ
UR::Object::Property is a subclass of UR::Object. it's giving legacy, it's giving lineage, it's giving "my parent is iconic" β¨
π PROPERTY TYPES π
okay so take this class definition, look at it, absorb it:
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, bestie:
- regular property β a regular property of a class holds a single scalar. in this case,
other_idis a regular property. one value, one vibe π - 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
isdeclaration).otheris 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's helpful for an object to assume the value of the remote class's properties, you can set up a
viaproperty. in the example above, an object of this class gets the value of itsbarproperty via theotherobject it's linked to, from that object'sbarproperty. it's giving "borrowed but make it fashion" β¨ - reverse as or is many property β this is how one-to-many relationships are implemented. in this case, the
Some::Fooclass must have an object accessor property calledsome, and thefoosproperty will return a list of all theSome::Fooobjects where theirsomeproperty would have returned that object. one object, many friends, periodt π - 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. math but make it meta π§
π PROPERTIES π
each property has a method of the same name. iykyk.
π 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 ofclass_nameand property name are the ID properties ofUR::Object::Property. literally the dynamic duo fr fr π«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 theispart of a class's property definition.data_length=> Number β the maximum size of data stored in this property πdefault_valueβ foris_optionalproperties, the default value given when an object is created and this property is not assigned a value. the fallback, the backup dancer, the understudy π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 classis_optional=> Boolean β indicates whether this is property may have the valueundefwhen the object is createdis_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. pick a lane bestie π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. sneaky little thing π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. group chat rules: one message, everyone sees it π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. undo button energy πis_abstract=> Boolean β indicates this property exists in a base class, but must be overridden in a derived class.is_concrete=> Boolean β antonym foris_abstract. properties cannot be bothis_abstractandis_concrete. not both, bestie, choose your fighter π₯is_final=> Boolean β indicates this property cannot be overridden in a derived class. it's giving "no takebacks" π«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. the caution tape is decorative but it IS there β οΈimplied_by=> Text β if this property is created as a result of another property's existence,implied_byis 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. surprise property, but in a cute way π
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 anis_manyrelationshipvia=> Text β for a via-type property, indicates which object accessor to go through. the middleman, the connector, the group chat admin π§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 asproperty_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. filtering? we love to see it π
calculate_from=> ARRAY β for calculated properties, this is a list of other property names the calculation is based oncalculate_perl=> Text β for calculated properties, a string containing Perl code. any properties mentioned incalculate_fromwill exist in the code's scope at run time as scalars of the same name. code-as-string, it's giving chaotic but it works β¨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 throughto_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 β go read those too bestie, they're all in the same friend group π«Ά
okay that's the whole thing, you ate it, no crumbs. this page came from perl v5.32.1 and it's dated 2022-01-17, so it's a lil vintage but it still slays πβ¨
π¦ where this page comes from
- debian bookworm: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libur-perl 0.470+ds-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms