X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod.pm;h=0789006940377b2fc74f45d70cb70bfe1d1363b1;hb=95637edb1de318b764f8ec2fc8b5c5c8d4430010;hp=458dbbb9e46cbe011ff35d5d69e6ddd76e87c6f1;hpb=034587d897c53d4df84085a9229334bd2d51f1c6;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 458dbbb..0789006 --- a/lib/Mouse/Meta/Method.pm +++ b/lib/Mouse/Meta/Method.pm @@ -1,28 +1,51 @@ package Mouse::Meta::Method; use Mouse::Util qw(:meta); # enables strict and warnings +use Scalar::Util (); use overload - '&{}' => 'body', + '==' => '_equal', + 'eq' => '_equal', + '&{}' => sub{ $_[0]->body }, fallback => 1, ; -sub new{ +sub wrap { + my $class = shift; + unshift @_, 'body' if @_ % 2 != 0; + return $class->_new(@_); +} + +sub _new{ my($class, %args) = @_; + my $self = bless \%args, $class; - return bless \%args, $class; + if($class ne __PACKAGE__){ + $self->meta->_initialize_object($self, \%args); + } + return $self; } -sub body { $_[0]->{body} } -sub name { $_[0]->{name} } -sub package_name{ $_[0]->{package} } +sub body { $_[0]->{body} } +sub name { $_[0]->{name} } +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; } -1; +# 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__ =head1 NAME @@ -31,7 +54,12 @@ Mouse::Meta::Method - A Mouse Method metaclass =head1 VERSION -This document describes Mouse version 0.40 +This document describes Mouse version 0.90 + +=head1 DESCRIPTION + +This class is a meta object protocol for Mouse methods, +which is a subset of Moose::Meta:::Method. =head1 SEE ALSO