X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod.pm;h=d455e760d927f53e363d95e5a901c7758c772a84;hb=c7ec86fc6a846dd4e08ebbfca2bf9808a951bfe4;hp=8bbb9444da1c33ea2f0b1417975efd4fd11ae946;hpb=6a97bbdad44391f2a587165cb81fcf8aedc642ac;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Method.pm b/lib/Mouse/Meta/Method.pm old mode 100755 new mode 100644 index 8bbb944..d455e76 --- a/lib/Mouse/Meta/Method.pm +++ b/lib/Mouse/Meta/Method.pm @@ -1,23 +1,28 @@ package Mouse::Meta::Method; use Mouse::Util qw(:meta); # enables strict and warnings +use Scalar::Util (); use overload + '==' => '_equal', + 'eq' => '_equal', '&{}' => sub{ $_[0]->body }, fallback => 1, ; -sub wrap{ +sub wrap { my $class = shift; - + unshift @_, 'body' if @_ % 2 != 0; return $class->_new(@_); } sub _new{ - my $class = shift; - return $class->meta->new_object(@_) - if $class ne __PACKAGE__; + my($class, %args) = @_; + my $self = bless \%args, $class; - return bless {@_}, $class; + if($class ne __PACKAGE__){ + $self->meta->_initialize_object($self, \%args); + } + return $self; } sub body { $_[0]->{body} } @@ -26,10 +31,20 @@ sub package_name { $_[0]->{package} } sub associated_metaclass { $_[0]->{associated_metaclass} } sub fully_qualified_name { - my $self = shift; + my($self) = @_; return $self->package_name . '::' . $self->name; } +# for Moose compat +sub _equal { + my($l, $r) = @_; + + return Scalar::Util::blessed($r) + && $l->body == $r->body + && $l->name eq $r->name + && $l->package_name eq $r->package_name; +} + 1; __END__ @@ -39,7 +54,12 @@ Mouse::Meta::Method - A Mouse Method metaclass =head1 VERSION -This document describes Mouse version 0.40_04 +This document describes Mouse version 0.95 + +=head1 DESCRIPTION + +This class is a meta object protocol for Mouse methods, +which is a subset of Moose::Meta:::Method. =head1 SEE ALSO