perldoc > Test2::Util::ExternalMeta

๐Ÿ“– NAME

Test2::Util::ExternalMeta โ€” Allow third party tools to safely attach metaโ€‘data to your instances.

๐Ÿš€ Quick Reference

Use CaseCommandDescription
Get meta value$obj->meta($key)Return value for $key, optionally setting a default if missing.
Get meta value (no default)$obj->get_meta($key)Return value for $key, without default overhead.
Set meta value$obj->set_meta($key, $val)Store a value under $key.
Delete meta value$obj->delete_meta($key)Remove the entry for $key and return the old value.

๐Ÿ“‹ DESCRIPTION

This package lets you define a clear, and consistent way to allow third party tools to attach metaโ€‘data to your instances. If your object consumes this package, and imports its methods, then third party metaโ€‘data has a safe place to live.

๐Ÿ“ SYNOPSIS

package My::Object;
use strict;
use warnings;

use Test2::Util::ExternalMeta qw/meta get_meta set_meta delete_meta/;

...

Now to use it:

my $inst = My::Object->new;

$inst->set_meta(foo => 'bar');
my $val = $inst->get_meta('foo');

๐Ÿ“Œ WHERE IS THE DATA STORED?

This package assumes your instances are blessed hashrefs; it will not work if that is not true. It will store all metaโ€‘data in the _meta key on your objectโ€™s hash. If your object makes use of the _meta key in its underlying hash, then there is a conflict and you cannot use this package.

๐Ÿ“š EXPORTS

๐Ÿ”‘ Meta-Key Restrictions

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

๐Ÿ“ฆ SOURCE

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

๐Ÿ‘ฅ MAINTAINERS

Chad Granum <exodist AT cpan.org>

โœ๏ธ AUTHORS

Chad Granum <exodist AT cpan.org>

ยฉ COPYRIGHT

Copyright 2020 Chad Granum <exodist AT cpan.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/

Test2::Util::ExternalMeta
๐Ÿ“– NAME ๐Ÿš€ Quick Reference ๐Ÿ“‹ DESCRIPTION ๐Ÿ“ SYNOPSIS
๐Ÿ“Œ WHERE IS THE DATA STORED?
๐Ÿ“š EXPORTS ๐Ÿ”‘ Meta-Key Restrictions ๐Ÿ“ฆ SOURCE ๐Ÿ‘ฅ MAINTAINERS โœ๏ธ AUTHORS ยฉ COPYRIGHT

Generated by phpman v4.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-09 22:18 @2600:1f28:365:80b0:35e2:9369:6b76:3018
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!