|
Revision 31976, 0.6 kB
(checked in by tokuhirom, 4 years ago)
|
|
use new_object instead of construct_instance
06:46 @autarch:> tokuhirom_: MX::Plaggerize is using ->construct_instance, you can switch
it to ->new_object and it should just work, but the former will be
deprecated soon
|
| Line | |
|---|
| 1 | use Moose; |
|---|
| 2 | use Test::More tests => 1; |
|---|
| 3 | use MooseX::Plaggerize; |
|---|
| 4 | |
|---|
| 5 | my $context = Moose::Meta::Class->create_anon_class( |
|---|
| 6 | roles => ['MooseX::Plaggerize'], |
|---|
| 7 | )->new_object; |
|---|
| 8 | |
|---|
| 9 | my $plugin = Moose::Meta::Class->create_anon_class()->new_object; |
|---|
| 10 | |
|---|
| 11 | { |
|---|
| 12 | $context->register_hook( |
|---|
| 13 | 'filter' => $plugin, |
|---|
| 14 | sub { |
|---|
| 15 | my ($self, $c, $txt) = @_; |
|---|
| 16 | $txt . '1'; |
|---|
| 17 | } |
|---|
| 18 | ); |
|---|
| 19 | $context->register_hook( |
|---|
| 20 | 'filter' => $plugin, |
|---|
| 21 | sub { |
|---|
| 22 | my ($self, $c, $txt) = @_; |
|---|
| 23 | $txt . '2'; |
|---|
| 24 | } |
|---|
| 25 | ); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | my ($got, ) = $context->run_hook_filter('filter', 'src'); |
|---|
| 29 | is $got, 'src12'; |
|---|
| 30 | |
|---|