Commit | Line | Data |
8ee73eeb |
1 | package Moose::Meta::Method; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
8ee73eeb |
6 | use base 'Class::MOP::Method'; |
7 | |
3e504337 |
8 | sub _error_thrower { |
9 | my $self = shift; |
bcc04ae1 |
10 | require Moose::Meta::Class; |
18748ad6 |
11 | ( ref $self && $self->associated_metaclass ) || "Moose::Meta::Class"; |
3e504337 |
12 | } |
13 | |
cee532a1 |
14 | sub throw_error { |
15 | my $self = shift; |
3e504337 |
16 | my $inv = $self->_error_thrower; |
cee532a1 |
17 | unshift @_, "message" if @_ % 2 == 1; |
18 | unshift @_, method => $self if ref $self; |
19 | unshift @_, $inv; |
ffa3d7bf |
20 | my $handler = $inv->can("throw_error"); |
21 | goto $handler; # to avoid incrementing depth by 1 |
cee532a1 |
22 | } |
23 | |
24 | sub _inline_throw_error { |
25 | my ( $self, $msg, $args ) = @_; |
bcc04ae1 |
26 | |
27 | my $inv = $self->_error_thrower; |
28 | # XXX ugh |
29 | $inv = 'Moose::Meta::Class' unless $inv->can('_inline_throw_error'); |
30 | |
31 | # XXX ugh ugh UGH |
32 | my $class = $self->associated_metaclass; |
33 | if ($class) { |
34 | my $class_name = B::perlstring($class->name); |
35 | my $meth_name = B::perlstring($self->name); |
36 | $args = 'method => Class::MOP::class_of(' . $class_name . ')' |
37 | . '->find_method_by_name(' . $meth_name . '), ' |
38 | . (defined $args ? $args : ''); |
39 | } |
40 | |
41 | return $inv->_inline_throw_error($msg, $args) |
cee532a1 |
42 | } |
43 | |
8ee73eeb |
44 | 1; |
45 | |
ad46f524 |
46 | # ABSTRACT: A Moose Method metaclass |
47 | |
8ee73eeb |
48 | __END__ |
49 | |
50 | =pod |
51 | |
39b3bc94 |
52 | =head1 DESCRIPTION |
53 | |
bef3ee55 |
54 | This class is a subclass of L<Class::MOP::Method> that provides |
e3177578 |
55 | additional Moose-specific functionality, all of which is private. |
39b3bc94 |
56 | |
bef3ee55 |
57 | To understand this class, you should read the the L<Class::MOP::Method> |
e3177578 |
58 | documentation. |
cee532a1 |
59 | |
d4b1449e |
60 | =head1 INHERITANCE |
61 | |
62 | C<Moose::Meta::Method> is a subclass of L<Class::MOP::Method>. |
63 | |
39b3bc94 |
64 | =head1 BUGS |
65 | |
d4048ef3 |
66 | See L<Moose/BUGS> for details on reporting bugs. |
39b3bc94 |
67 | |
cee532a1 |
68 | =cut |