2b8a820850808ac67dcaf2f78f1cb6d651815741
[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.72';
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     ( ref $self && $self->associated_metaclass ) || "Moose::Meta::Class";
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     my $handler = $inv->can("throw_error");
24     goto $handler; # to avoid incrementing depth by 1
25 }
26
27 sub _inline_throw_error {
28     my ( $self, $msg, $args ) = @_;
29     "\$meta->throw_error($msg" . ($args ? ", $args" : "") . ")"; # FIXME makes deparsing *REALLY* hard
30 }
31
32 1;
33
34 __END__
35
36 =pod
37
38 =head1 NAME
39
40 Moose::Meta::Method - A Moose Method metaclass
41
42 =head1 DESCRIPTION
43
44 This class is a subclass of L<Class::MOP::Class> that provides
45 additional Moose-specific functionality, all of which is private.
46
47 To understand this class, you should read the the L<Class::MOP::Class>
48 documentation.
49
50 =head1 BUGS
51
52 All complex software has bugs lurking in it, and this module is no 
53 exception. If you find a bug please either email me, or add the bug
54 to cpan-RT.
55
56 =head1 AUTHOR
57
58 Stevan Little E<lt>stevan@iinteractive.comE<gt>
59
60 =head1 COPYRIGHT AND LICENSE
61
62 Copyright 2006-2009 by Infinity Interactive, Inc.
63
64 L<http://www.iinteractive.com>
65
66 This library is free software; you can redistribute it and/or modify
67 it under the same terms as Perl itself.
68
69 =cut