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