1Object::Pad::MOP::FieldU(s3eprm)Contributed Perl DocumenOtbajteicotn::Pad::MOP::Field(3pm)
2
3
4
6 "Object::Pad::MOP::Field" - meta-object representation of data field of
7 a "Object::Pad" class
8
10 Instances of this class represent a data field of a class implemented
11 by Object::Pad. Accessors provide information about the field. The
12 special "value" method allows access to the value of the given field on
13 instances of its class, letting the meta-object be used as a proxy to
14 it.
15
16 This API should be considered experimental, and will emit warnings to
17 that effect. They can be silenced with
18
19 use Object::Pad qw( :experimental(mop) );
20
22 name
23 $name = $metafield->name
24
25 Returns the name of the field, as a plain string including the leading
26 sigil character.
27
28 sigil
29 $sigil = $metafield->sigil
30
31 Since version 0.56.
32
33 Returns the first character of the field name, giving just its leading
34 sigil.
35
36 class
37 $metaclass = $metafield->class
38
39 Returns the Object::Pad::MOP::Class instance representing the class of
40 which this field is a member.
41
42 value
43 $current = $metafield->value( $instance )
44 @current = $metafield->value( $instance )
45 %current = $metafield->value( $instance )
46
47 An accessor method which returns the current value of the field from an
48 object instance.
49
50 $metafield->value( $instance ) = $new
51
52 On scalar fields, this method can also act as an lvalue mutator
53 allowing a new value to be set.
54
55 has_attribute
56 $exists = $metafield->has_attribute( $name )
57
58 Since version 0.57.
59
60 Returns a boolean indicating whether the named attribute has been
61 attached to the field. The attribute name should not include the
62 leading colon (":") character.
63
64 get_attribute_value
65 $value = $metafield->get_attribute_value( $name )
66
67 Since version 0.57.
68
69 Returns the stored value of an attached attribute, if one exists. If
70 the attribute has not been attached then an exception is thrown.
71
72 Note that most core-defined attributes will either store no data at
73 all, or a method name string. This accessor method is provided largely
74 for the benefit of obtaining data defined by third-party attributes,
75 which may more clearly define how that data is generated and used.
76
77 get_attribute_values
78 @values = $metafield->get_attribute_values( $name )
79
80 Since version 0.66.
81
82 Returns all the stored values of an attached attribute, if one exists.
83 If the attribute has not been attached then an exception is thrown.
84
85 This allows inspection of stored attribute values if it makes
86 meaningful sense for the attribute to be applied multiple times to the
87 same field. This is unlikely to be useful for core-defined attributes,
88 but may be meaningful for third-party attributes.
89
91 Paul Evans <leonerd@leonerd.org.uk>
92
93
94
95perl v5.38.0 2023-08-10 Object::Pad::MOP::Field(3pm)