Move the generation of delegation methods into MM::Method::Delegation itself.
[gitmo/Moose.git] / lib / Moose / Meta / Method.pm
CommitLineData
8ee73eeb 1package Moose::Meta::Method;
2
3use strict;
4use warnings;
5
e606ae5f 6our $VERSION = '0.57';
7$VERSION = eval $VERSION;
d44714be 8our $AUTHORITY = 'cpan:STEVAN';
8ee73eeb 9
10use base 'Class::MOP::Method';
11
3e504337 12sub _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 18sub 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
28sub _inline_throw_error {
29 my ( $self, $msg, $args ) = @_;
30 "\$meta->throw_error($msg" . ($args ? ", $args" : "") . ")"; # FIXME makes deparsing *REALLY* hard
31}
32
8ee73eeb 331;
34
35__END__
36
37=pod
38
39b3bc94 39=head1 NAME
40
ecb59493 41Moose::Meta::Method - A Moose Method metaclass
39b3bc94 42
43=head1 DESCRIPTION
44
ecb59493 45For now, this is nothing but a subclass of Class::MOP::Method,
46but with the expanding role of the method sub-protocol, it might
47be 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
61All complex software has bugs lurking in it, and this module is no
62exception. If you find a bug please either email me, or add the bug
63to cpan-RT.
64
65=head1 AUTHOR
66
67Stevan Little E<lt>stevan@iinteractive.comE<gt>
68
39b3bc94 69=head1 COPYRIGHT AND LICENSE
70
778db3ac 71Copyright 2006-2008 by Infinity Interactive, Inc.
39b3bc94 72
73L<http://www.iinteractive.com>
74
75This library is free software; you can redistribute it and/or modify
76it under the same terms as Perl itself.
77
cee532a1 78=cut