X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod.pm;h=be03cfff22ded26be6df1dae179c394d7cf169d8;hp=763e532d381e6f1770e5e9921fc629f7986b39fe;hb=e128626c409797822ffd8a4079f833eb3dc0fd37;hpb=6cfa1e5e70616fb102915489c02d8347ffa912fb diff --git a/lib/Mouse/Meta/Method.pm b/lib/Mouse/Meta/Method.pm index 763e532..be03cff 100755 --- a/lib/Mouse/Meta/Method.pm +++ b/lib/Mouse/Meta/Method.pm @@ -1,23 +1,52 @@ -package Mouse::Meta::Method; -use strict; -use warnings; - -use overload - '&{}' => 'body', - fallback => 1, -; - -sub new{ - my($class, %args) = @_; - - return bless \%args, $class; -} - -sub body { $_[0]->{body} } -sub name { $_[0]->{name} } -sub package{ $_[0]->{name} } - - -1; - -__END__ +package Mouse::Meta::Method; +use Mouse::Util qw(:meta); # enables strict and warnings + +use overload + '&{}' => sub{ $_[0]->body }, + fallback => 1, +; + +sub wrap{ + my $class = shift; + + return $class->_new(@_); +} + +sub _new{ + my($class, %args) = @_; + my $self = 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 associated_metaclass { $_[0]->{associated_metaclass} } + +sub fully_qualified_name { + my($self) = @_; + return $self->package_name . '::' . $self->name; +} + +1; +__END__ + +=head1 NAME + +Mouse::Meta::Method - A Mouse Method metaclass + +=head1 VERSION + +This document describes Mouse version 0.50_01 + +=head1 SEE ALSO + +L + +L + +=cut