This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Sync Test-Simple with CPAN version 1.302173
[perl5.git] / cpan / Test-Simple / lib / Test2 / EventFacet / Meta.pm
CommitLineData
07bc328a
SH
1package Test2::EventFacet::Meta;
2use strict;
3use warnings;
4
d4d3249e 5our $VERSION = '1.302173';
07bc328a
SH
6
7BEGIN { require Test2::EventFacet; our @ISA = qw(Test2::EventFacet) }
8use vars qw/$AUTOLOAD/;
9
10# replace set_details
11{
12 no warnings 'redefine';
13 sub set_details { $_[0]->{'set_details'} }
14}
15
16sub can {
17 my $self = shift;
18 my ($name) = @_;
19
20 my $existing = $self->SUPER::can($name);
21 return $existing if $existing;
22
23 # Only vivify when called on an instance, do not vivify for a class. There
24 # are a lot of magic class methods used in things like serialization (or
25 # the forks.pm module) which cause problems when vivified.
26 return undef unless ref($self);
27
28 my $sub = sub { $_[0]->{$name} };
29 {
30 no strict 'refs';
31 *$name = $sub;
32 }
33
34 return $sub;
35}
36
37sub AUTOLOAD {
38 my $name = $AUTOLOAD;
39 $name =~ s/^.*:://g;
40 my $sub = $_[0]->can($name);
41 goto &$sub;
42}
43
441;
45
46__END__
47
48=pod
49
50=encoding UTF-8
51
52=head1 NAME
53
54Test2::EventFacet::Meta - Facet for meta-data
55
56=head1 DESCRIPTION
57
58This facet can contain any random meta-data that has been attached to the
59event.
60
61=head1 METHODS AND FIELDS
62
63Any/all fields and accessors are autovivified into existence. There is no way
64to know what metadata may be added, so any is allowed.
65
66=over 4
67
68=item $anything = $meta->{anything}
69
70=item $anything = $meta->anything()
71
72=back
73
74=head1 SOURCE
75
76The source code repository for Test2 can be found at
77F<http://github.com/Test-More/test-more/>.
78
79=head1 MAINTAINERS
80
81=over 4
82
83=item Chad Granum E<lt>exodist@cpan.orgE<gt>
84
85=back
86
87=head1 AUTHORS
88
89=over 4
90
91=item Chad Granum E<lt>exodist@cpan.orgE<gt>
92
93=back
94
95=head1 COPYRIGHT
96
c4178f71 97Copyright 2019 Chad Granum E<lt>exodist@cpan.orgE<gt>.
07bc328a
SH
98
99This program is free software; you can redistribute it and/or
100modify it under the same terms as Perl itself.
101
102See F<http://dev.perl.org/licenses/>
103
104=cut