X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FReaction%2FClass.pm;h=64116ceb44ec52c168cc82813d0812cb3908168a;hb=7826ddacc81a92495f4598a6d7038fb8e02a209c;hp=fcaf0a55e1ab14e6bac38e9d0210543c094a095c;hpb=1810d30231d48a745bab3931c18044bc19c85e61;p=catagits%2FReaction.git diff --git a/lib/Reaction/Class.pm b/lib/Reaction/Class.pm index fcaf0a5..64116ce 100644 --- a/lib/Reaction/Class.pm +++ b/lib/Reaction/Class.pm @@ -3,7 +3,7 @@ package Reaction::Class; use Moose qw(confess); use Sub::Exporter (); use Sub::Name (); -use Reaction::Types::Core; +use Reaction::Types::Core ':all'; use Reaction::Object; sub exporter_for_package { @@ -147,15 +147,20 @@ sub setup_and_cleanup { shift if $_[0] eq 'as'; push(@methods, [ $name, shift ]); }; + my $s = $setup; foreach my $meth ($self->delayed_methods) { $save_delayed{$meth} = $package->can($meth); - local *{"${package}::${meth}"} = - Sub::Name::subname "${self}::${meth}" => sub { - push(@apply_after, [ $meth => @_ ]); - }; + my $s_copy = $s; + $s = sub { + local *{"${package}::${meth}"} = + Sub::Name::subname "${self}::${meth}" => sub { + push(@apply_after, [ $meth => @_ ]); + }; + $s_copy->(@_); + }; } # XXX - need additional fuckery to handle multi-class-per-file - $setup->(); # populate up the crap + $s->(); # populate up the crap } my %exports = $self->exports_for_package($package); { @@ -168,7 +173,7 @@ sub setup_and_cleanup { eval "package ${package}; no $unimport_class;"; confess "$unimport_class unimport from ${package} failed: $@" if $@; foreach my $m (@methods) { - $package->meta->add_method(@$m); + $self->add_method_to_target($package, $m); } foreach my $a (@apply_after) { my $call = shift(@$a); @@ -176,6 +181,11 @@ sub setup_and_cleanup { } } +sub add_method_to_target { + my ($self, $target, $method) = @_; + $target->meta->add_method(@$method); +} + sub delayed_methods { return (qw/has with extends before after around override augment/); }