Beginning of dzilization
[gitmo/Moose.git] / lib / Moose / Meta / Method.pm
1 package Moose::Meta::Method;
2
3 use strict;
4 use warnings;
5
6 our $AUTHORITY = 'cpan:STEVAN';
7
8 use Class::MOP::MiniTrait;
9
10 use base 'Class::MOP::Method';
11
12 Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
13
14 sub _error_thrower {
15     my $self = shift;
16     ( ref $self && $self->associated_metaclass ) || "Moose::Meta::Class";
17 }
18
19 sub throw_error {
20     my $self = shift;
21     my $inv = $self->_error_thrower;
22     unshift @_, "message" if @_ % 2 == 1;
23     unshift @_, method => $self if ref $self;
24     unshift @_, $inv;
25     my $handler = $inv->can("throw_error");
26     goto $handler; # to avoid incrementing depth by 1
27 }
28
29 sub _inline_throw_error {
30     my ( $self, $msg, $args ) = @_;
31     "\$meta->throw_error($msg" . ($args ? ", $args" : "") . ")"; # FIXME makes deparsing *REALLY* hard
32 }
33
34 1;
35
36 # ABSTRACT: A Moose Method metaclass
37
38 __END__
39
40 =pod
41
42 =head1 DESCRIPTION
43
44 This class is a subclass of L<Class::MOP::Method> 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::Method>
48 documentation.
49
50 =head1 INHERITANCE
51
52 C<Moose::Meta::Method> is a subclass of L<Class::MOP::Method>.
53
54 =head1 BUGS
55
56 See L<Moose/BUGS> for details on reporting bugs.
57
58 =cut