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