| 1 | # ABSTRACT: Make MooseX::Event methods available as class methods on a singleton | ||
| 2 | package MooseX::Event::Role::ClassMethods; | ||
| 3 | { | ||
| 4 | $MooseX::Event::Role::ClassMethods::VERSION = 'v0.2.0'; | ||
| 5 | } | ||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | use Any::Moose 'Role'; | ||
| 9 | |||
| 10 | requires 'instance'; | ||
| 11 | |||
| 12 | around [qw( event_exists on once emit remove_all_listeners remove_listener )] => sub { | ||
| 13 | my $orig = shift; | ||
| 14 | if ( ! ref $_[0] ) { | ||
| 15 | my $class = shift; | ||
| 16 | unshift @_, $class->instance; | ||
| 17 | } | ||
| 18 | goto $orig; | ||
| 19 | }; | ||
| 20 | |||
| 21 | no Any::Moose 'Role'; | ||
| 22 | |||
| 23 | 1; | ||
| 24 | |||
| 25 | |||
| 26 | __END__ |