1Object::Pad::MOP::FieldUAstetrr(C3o)ntributed Perl DocumOebnjteactti:o:nPad::MOP::FieldAttr(3)
2
3
4

NAME

6       "Object::Pad::MOP::FieldAttr" - meta-object representation of a field
7       attribute for "Object::Pad"
8

DESCRIPTION

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
19       This API should be considered experimental, and will emit warnings to
20       that effect. They can be silenced with
21
22          use Object::Pad qw( :experimental(custom_field_attr) );
23

METHODS

25   register
26          Object::Pad::MOP::FieldAttr->register( $name, %args )
27
28       Since version 0.60.
29
30       Creates a new field attribute of the given name. The name must begin
31       with a capital letter, in order to distinguish this from any of the
32       built-in core attributes, whose names are lowercase.
33
34       The attribute is only available if the hints hash contains a key of the
35       name given by the attribute's "permit_hintkey" argument. This would
36       typically be set in the hints hash by the "import" method of the module
37       implementing it, and would be named based on the name of the module
38       providing the attribute:
39
40          sub import { $^H{"Some::Package::Name/Attrname"} }
41
42       Takes the following additional named arguments:
43
44       permit_hintkey => STRING
45           Required. A string giving a key that must be found in the hints
46           hash ("%^H") for this attribute name to be visible.
47
48       apply => CODE
49           An optional code reference for a callback function to invoke when
50           the attribute is applied to a field. If present, it is passed the
51           field metadata instance as a Object::Pad::MOP::Field reference, and
52           a string containing the contents of the attribute's parenthesized
53           value. The return value of the callback will be stored as the
54           attribute's value and can be accessed by the "get_attribute_value"
55           method on the field metadata.
56
57              $result = $apply->( $fieldmeta, $value )
58
59           If the "apply" callback is absent then the string value itself is
60           stored.
61

AUTHOR

63       Paul Evans <leonerd@leonerd.org.uk>
64
65
66
67perl v5.36.0                      2022-12-01    Object::Pad::MOP::FieldAttr(3)
Impressum