Commit | Line | Data |
---|---|---|
8e50c419 | 1 | package TestMethods; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | sub import { | |
7 | my ( $class, @methods ) = @_; | |
8 | my $target = caller; | |
9 | ||
10 | foreach my $method (@methods) { | |
11 | my $fq_method = $target . "::$method"; | |
12 | no strict 'refs'; | |
13 | *$fq_method = sub { | |
14 | local *__ANON__ = "__ANON__$fq_method"; | |
15 | my $self = shift; | |
16 | return $self->{$method} unless @_; | |
17 | $self->{$method} = shift; | |
18 | return $self; | |
19 | }; | |
20 | } | |
21 | } | |
22 | ||
23 | 1; |