Commit | Line | Data |
---|---|---|
8e64d0fa | 1 | package Mouse::Meta::Method; |
bc69ee88 | 2 | use Mouse::Util qw(:meta); # enables strict and warnings |
81eaf8eb | 3 | use Scalar::Util (); |
53875581 | 4 | |
8e64d0fa | 5 | use overload |
81eaf8eb | 6 | '==' => '_equal', |
7 | 'eq' => '_equal', | |
ef206305 | 8 | '&{}' => sub{ $_[0]->body }, |
8e64d0fa | 9 | fallback => 1, |
10 | ; | |
11 | ||
9010458d | 12 | sub wrap{ |
13 | my $class = shift; | |
8e64d0fa | 14 | |
9010458d | 15 | return $class->_new(@_); |
8e64d0fa | 16 | } |
17 | ||
9010458d | 18 | sub _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 | ||
28 | sub body { $_[0]->{body} } | |
29 | sub name { $_[0]->{name} } | |
30 | sub package_name { $_[0]->{package} } | |
31 | sub associated_metaclass { $_[0]->{associated_metaclass} } | |
8e64d0fa | 32 | |
612d3e1a | 33 | sub fully_qualified_name { |
cf59b715 | 34 | my($self) = @_; |
612d3e1a | 35 | return $self->package_name . '::' . $self->name; |
36 | } | |
8e64d0fa | 37 | |
81eaf8eb | 38 | # for Moose compat |
39 | sub _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 | 48 | 1; |
8e64d0fa | 49 | __END__ |
1820fffe | 50 | |
51 | =head1 NAME | |
52 | ||
53 | Mouse::Meta::Method - A Mouse Method metaclass | |
54 | ||
a25ca8d6 | 55 | =head1 VERSION |
56 | ||
86eb0b5e | 57 | This document describes Mouse version 0.70 |
a25ca8d6 | 58 | |
503ed648 | 59 | =head1 DESCRIPTION |
60 | ||
61 | This class is a meta object protocol for Mouse methods, | |
62 | which is a subset of Moose::Meta:::Method. | |
63 | ||
1820fffe | 64 | =head1 SEE ALSO |
65 | ||
66 | L<Moose::Meta::Method> | |
67 | ||
31c5194b | 68 | L<Class::MOP::Method> |
69 | ||
1820fffe | 70 | =cut |