1Object::Pad::MOP::FieldUAstetrr(C3o)ntributed Perl DocumOebnjteactti:o:nPad::MOP::FieldAttr(3)
2
3
4
6 "Object::Pad::MOP::FieldAttr" - meta-object representation of a field
7 attribute for "Object::Pad"
8
10 This API provides a way for pure-perl implementations of field
11 attributes to be provided. Pure-perl attributes cannot currently add
12 new behaviour to the way that fields work, but they do provide a means
13 for class authors to annotate extra metadata onto fields, that can be
14 queried by other code.
15
16 Primilarily this is done by using the "get_attribute_value" in
17 Object::Pad::MOP::Field accessor method on a field metadata instance.
18
20 register
21 Object::Pad::MOP::FieldAttr->register( $name, %args )
22
23 Since version 0.60.
24
25 Creates a new field attribute of the given name. The name must begin
26 with a capital letter, in order to distinguish this from any of the
27 built-in core attributes, whose names are lowercase.
28
29 The attribute is only available if the hints hash contains a key of the
30 name given by the attribute's "permit_hintkey" argument. This would
31 typically be set in the hints hash by the "import" method of the module
32 implementing it, and would be named based on the name of the module
33 providing the attribute:
34
35 sub import { $^H{"Some::Package::Name/Attrname"} }
36
37 Takes the following additional named arguments:
38
39 permit_hintkey => STRING
40 Required. A string giving a key that must be found in the hints
41 hash ("%^H") for this attribute name to be visible.
42
43 apply => CODE
44 An optional code reference for a callback function to invoke when
45 the attribute is applied to a field. If present, it is passed the
46 field metadata instance as a Object::Pad::MOP::Field reference, and
47 a string containing the contents of the attribute's parenthesized
48 value. The return value of the callback will be stored as the
49 attribute's value and can be accessed by the "get_attribute_value"
50 method on the field metadata.
51
52 $result = $apply->( $fieldmeta, $value )
53
54 If the "apply" callback is absent then the string value itself is
55 stored.
56
58 Paul Evans <leonerd@leonerd.org.uk>
59
60
61
62perl v5.34.0 2022-03-02 Object::Pad::MOP::FieldAttr(3)