This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Test-Simple to CPAN version 1.302181
[perl5.git] / cpan / Test-Simple / lib / Test2 / EventFacet / Meta.pm
1 package Test2::EventFacet::Meta;
2 use strict;
3 use warnings;
4
5 our $VERSION = '1.302181';
6
7 BEGIN { require Test2::EventFacet; our @ISA = qw(Test2::EventFacet) }
8 use vars qw/$AUTOLOAD/;
9
10 # replace set_details
11 {
12     no warnings 'redefine';
13     sub set_details { $_[0]->{'set_details'} }
14 }
15
16 sub 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
37 sub AUTOLOAD {
38     my $name = $AUTOLOAD;
39     $name =~ s/^.*:://g;
40     my $sub = $_[0]->can($name);
41     goto &$sub;
42 }
43
44 1;
45
46 __END__
47
48 =pod
49
50 =encoding UTF-8
51
52 =head1 NAME
53
54 Test2::EventFacet::Meta - Facet for meta-data
55
56 =head1 DESCRIPTION
57
58 This facet can contain any random meta-data that has been attached to the
59 event.
60
61 =head1 METHODS AND FIELDS
62
63 Any/all fields and accessors are autovivified into existence. There is no way
64 to 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
76 The source code repository for Test2 can be found at
77 F<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
97 Copyright 2020 Chad Granum E<lt>exodist@cpan.orgE<gt>.
98
99 This program is free software; you can redistribute it and/or
100 modify it under the same terms as Perl itself.
101
102 See F<http://dev.perl.org/licenses/>
103
104 =cut