Merge branch 'master' of github.com:gfx/p5-Mouse-temporary
[gitmo/Mouse.git] / lib / Mouse / Meta / Method.pm
CommitLineData
8e64d0fa 1package Mouse::Meta::Method;
bc69ee88 2use Mouse::Util qw(:meta); # enables strict and warnings
81eaf8eb 3use Scalar::Util ();
53875581 4
8e64d0fa 5use overload
81eaf8eb 6 '==' => '_equal',
7 'eq' => '_equal',
ef206305 8 '&{}' => sub{ $_[0]->body },
8e64d0fa 9 fallback => 1,
10;
11
f530c77b 12sub wrap {
9010458d 13 my $class = shift;
f530c77b 14 unshift @_, 'body' if @_ % 2 != 0;
9010458d 15 return $class->_new(@_);
8e64d0fa 16}
17
9010458d 18sub _new{
e78cd29d 19 my($class, %args) = @_;
20 my $self = bless \%args, $class;
9010458d 21
e78cd29d 22 if($class ne __PACKAGE__){
23 $self->meta->_initialize_object($self, \%args);
24 }
25 return $self;
9010458d 26}
27
28sub body { $_[0]->{body} }
29sub name { $_[0]->{name} }
30sub package_name { $_[0]->{package} }
31sub associated_metaclass { $_[0]->{associated_metaclass} }
8e64d0fa 32
612d3e1a 33sub fully_qualified_name {
cf59b715 34 my($self) = @_;
612d3e1a 35 return $self->package_name . '::' . $self->name;
36}
8e64d0fa 37
81eaf8eb 38# for Moose compat
39sub _equal {
40 my($l, $r) = @_;
41
42 return Scalar::Util::blessed($r)
43 && $l->body == $r->body
44 && $l->name eq $r->name
45 && $l->package_name eq $r->package_name;
46}
47
8e64d0fa 481;
8e64d0fa 49__END__
1820fffe 50
51=head1 NAME
52
53Mouse::Meta::Method - A Mouse Method metaclass
54
a25ca8d6 55=head1 VERSION
56
14cf9b5a 57This document describes Mouse version 0.95
a25ca8d6 58
503ed648 59=head1 DESCRIPTION
60
61This class is a meta object protocol for Mouse methods,
62which is a subset of Moose::Meta:::Method.
63
1820fffe 64=head1 SEE ALSO
65
66L<Moose::Meta::Method>
67
31c5194b 68L<Class::MOP::Method>
69
1820fffe 70=cut