Skip to content

Commit

Permalink
Kill MooseX::Async and migrate to Attribute::Native
Browse files Browse the repository at this point in the history
  • Loading branch information
perigrin committed Oct 8, 2009
1 parent fa245af commit 269d0ae
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 5 deletions.
1 change: 0 additions & 1 deletion Makefile.PL
Expand Up @@ -7,7 +7,6 @@ all_from 'lib/MooseX/POE.pm';

# Specific dependencies
requires 'Moose' => '0.73';
requires 'MooseX::Async' => '0.07';
requires 'POE' => '1.004';
requires 'Sub::Name' => '0.04';

Expand Down
9 changes: 9 additions & 0 deletions lib/MooseX/POE/Meta/Method/State.pm
@@ -0,0 +1,9 @@
package MooseX::POE::Meta::Method::State;
use strict;
use Moose;
extends qw(Moose::Meta::Method);

no Moose;
1;
__END__
2 changes: 1 addition & 1 deletion lib/MooseX/POE/Meta/Role.pm
@@ -1,6 +1,6 @@
package MooseX::POE::Meta::Role;
use Moose::Role;
with qw(MooseX::Async::Meta::Trait);
with qw(MooseX::POE::Meta::Trait);

around default_events => sub {
my ($orig, $self) = @_;
Expand Down
46 changes: 46 additions & 0 deletions lib/MooseX/POE/Meta/Trait.pm
@@ -0,0 +1,46 @@
package MooseX::POE::Meta::Trait;
use Moose::Role;

use MooseX::POE::Meta::Method::State;

has events => (
reader => 'get_events',
traits => ['Array'],
isa => 'ArrayRef',
auto_deref => 1,
lazy_build => 1,
builder => 'default_events',
handles => { 'add_event' => ['push'] },
);

sub default_events {
return [];
}

sub get_state_method_name {
my ( $self, $name ) = @_;
return $name if $self->has_method($name);
return undef;
}

sub add_state_method {
my ( $self, $name, $method ) = @_;
if ( $self->has_method($name) ) {
my $full_name = $self->get_method($name)->fully_qualified_name;
confess
"Cannot add a state method ($name) if a local method ($full_name) is already present";
}

$self->add_event($name);
$self->add_method( $name => $method );
}

after add_role => sub {
my ( $self, $role ) = @_;

if ( $role->isa("MooseX::POE::Meta::Role") ) {
$self->add_event( $role->get_events );
}
};

1;
6 changes: 3 additions & 3 deletions lib/MooseX/POE/Meta/Trait/Class.pm
Expand Up @@ -2,7 +2,7 @@ package MooseX::POE::Meta::Trait::Class;

use Moose::Role;

with qw(MooseX::Async::Meta::Trait);
with qw(MooseX::POE::Meta::Trait);

# TODO: subclass events to be a hashref that maps the event to the method
# so we can support on_ events
Expand All @@ -18,7 +18,7 @@ around add_role => sub {
my ( $next, $self, $role ) = @_;
$next->( $self, $role );
if ( $role->meta->can('does_role')
&& $role->meta->does_role("MooseX::Async::Meta::Trait") ) {
&& $role->meta->does_role("MooseX::POE::Meta::Trait") ) {
$self->add_event( $role->get_events );
}
};
Expand All @@ -31,7 +31,7 @@ around get_state_method_name => sub {

sub get_all_events {
my ($self) = @_;
my $wanted_role = 'MooseX::Async::Meta::Trait';
my $wanted_role = 'MooseX::POE::Meta::Trait';

# This horrible grep can be removed once Moose gets more metacircular.
# Currently Moose::Meta::Class->meta isn't a MMC. It should be, and it
Expand Down

0 comments on commit 269d0ae

Please sign in to comment.