1Test2::Util::ExternalMeUtsae(r3)Contributed Perl DocumenTteastti2o:n:Util::ExternalMeta(3)
2
3
4

NAME

6       Test2::Util::ExternalMeta - Allow third party tools to safely attach
7       meta-data to your instances.
8

DESCRIPTION

10       This package lets you define a clear, and consistent way to allow third
11       party tools to attach meta-data to your instances. If your object
12       consumes this package, and imports its methods, then third party meta-
13       data has a safe place to live.
14

SYNOPSIS

16           package My::Object;
17           use strict;
18           use warnings;
19
20           use Test2::Util::ExternalMeta qw/meta get_meta set_meta delete_meta/;
21
22           ...
23
24       Now to use it:
25
26           my $inst = My::Object->new;
27
28           $inst->set_meta(foo => 'bar');
29           my $val = $inst->get_meta('foo');
30

WHERE IS THE DATA STORED?

32       This package assumes your instances are blessed hashrefs, it will not
33       work if that is not true. It will store all meta-data in the "_meta"
34       key on your objects hash. If your object makes use of the "_meta" key
35       in its underlying hash, then there is a conflict and you cannot use
36       this package.
37

EXPORTS

39       $val = $obj->meta($key)
40       $val = $obj->meta($key, $default)
41           This will get the value for a specified meta $key. Normally this
42           will return "undef" when there is no value for the $key, however
43           you can specify a $default value to set when no value is already
44           set.
45
46       $val = $obj->get_meta($key)
47           This will get the value for a specified meta $key. This does not
48           have the $default overhead that meta() does.
49
50       $val = $obj->delete_meta($key)
51           This will remove the value of a specified meta $key. The old $val
52           will be returned.
53
54       $obj->set_meta($key, $val)
55           Set the value of a specified meta $key.
56

META-KEY RESTRICTIONS

58       Meta keys must be defined, and must be true when used as a boolean.
59       Keys may not be references. You are free to stringify a reference
60       "$ref" for use as a key, but this package will not stringify it for
61       you.
62

SOURCE

64       The source code repository for Test2 can be found at
65       http://github.com/Test-More/test-more/.
66

MAINTAINERS

68       Chad Granum <exodist@cpan.org>
69

AUTHORS

71       Chad Granum <exodist@cpan.org>
72
74       Copyright 2020 Chad Granum <exodist@cpan.org>.
75
76       This program is free software; you can redistribute it and/or modify it
77       under the same terms as Perl itself.
78
79       See http://dev.perl.org/licenses/
80
81
82
83perl v5.36.0                      2023-03-15      Test2::Util::ExternalMeta(3)
Impressum