Move the generation of delegation methods into MM::Method::Delegation itself.
[gitmo/Moose.git] / lib / Moose / Meta / Method.pm
1 package Moose::Meta::Method;
2
3 use strict;
4 use warnings;
5
6 our $VERSION   = '0.57';
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
9
10 use base 'Class::MOP::Method';
11
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
18 sub throw_error {
19     my $self = shift;
20     my $inv = $self->_error_thrower;
21     unshift @_, "message" if @_ % 2 == 1;
22     unshift @_, method => $self if ref $self;
23     unshift @_, $inv;
24     my $handler = $inv->can("throw_error");
25     goto $handler; # to avoid incrementing depth by 1
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
33 1;
34
35 __END__
36
37 =pod
38
39 =head1 NAME
40
41 Moose::Meta::Method - A Moose Method metaclass
42
43 =head1 DESCRIPTION
44
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. 
48
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
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
69 =head1 COPYRIGHT AND LICENSE
70
71 Copyright 2006-2008 by Infinity Interactive, Inc.
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
78 =cut