Commit | Line | Data |
8ee73eeb |
1 | package Moose::Meta::Method; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
e606ae5f |
6 | our $VERSION = '0.57'; |
7 | $VERSION = eval $VERSION; |
d44714be |
8 | our $AUTHORITY = 'cpan:STEVAN'; |
8ee73eeb |
9 | |
10 | use base 'Class::MOP::Method'; |
11 | |
3e504337 |
12 | sub _error_thrower { |
13 | my $self = shift; |
14 | return "Moose::Meta::Class"; |
15 | #( $self->associated_attribute || $self->associated_class ) # FIXME move to Accessor, fix for Constructor |
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 ) = @_; |
30 | "\$meta->throw_error($msg" . ($args ? ", $args" : "") . ")"; # FIXME makes deparsing *REALLY* hard |
31 | } |
32 | |
8ee73eeb |
33 | 1; |
34 | |
35 | __END__ |
36 | |
37 | =pod |
38 | |
39b3bc94 |
39 | =head1 NAME |
40 | |
ecb59493 |
41 | Moose::Meta::Method - A Moose Method metaclass |
39b3bc94 |
42 | |
43 | =head1 DESCRIPTION |
44 | |
ecb59493 |
45 | For now, this is nothing but a subclass of Class::MOP::Method, |
46 | but with the expanding role of the method sub-protocol, it might |
47 | be more useful later on. |
39b3bc94 |
48 | |
cee532a1 |
49 | =head1 METHODS |
50 | |
51 | =over 4 |
52 | |
53 | =item throw_error $msg, %args |
54 | |
55 | =item _inline_throw_error $msg_expr, $args_expr |
56 | |
57 | =back |
58 | |
39b3bc94 |
59 | =head1 BUGS |
60 | |
61 | All complex software has bugs lurking in it, and this module is no |
62 | exception. If you find a bug please either email me, or add the bug |
63 | to cpan-RT. |
64 | |
65 | =head1 AUTHOR |
66 | |
67 | Stevan Little E<lt>stevan@iinteractive.comE<gt> |
68 | |
39b3bc94 |
69 | =head1 COPYRIGHT AND LICENSE |
70 | |
778db3ac |
71 | Copyright 2006-2008 by Infinity Interactive, Inc. |
39b3bc94 |
72 | |
73 | L<http://www.iinteractive.com> |
74 | |
75 | This library is free software; you can redistribute it and/or modify |
76 | it under the same terms as Perl itself. |
77 | |
cee532a1 |
78 | =cut |