X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod.pm;h=74cbe8d03f55a2e4359b4592a9586f8be7c8780c;hb=b7d4b35d8beb17c48cf3f08c386cf863d973a7db;hp=7257c72679542cd59bdcb52d81b8f819eecee724;hpb=fb4fcfee39263ca3983e28f840f38185282d4327;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method.pm b/lib/Moose/Meta/Method.pm index 7257c72..74cbe8d 100644 --- a/lib/Moose/Meta/Method.pm +++ b/lib/Moose/Meta/Method.pm @@ -3,45 +3,70 @@ package Moose::Meta::Method; use strict; use warnings; -our $VERSION = '0.57'; -$VERSION = eval $VERSION; -our $AUTHORITY = 'cpan:STEVAN'; +use Class::MOP::MiniTrait; use base 'Class::MOP::Method'; +Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); + +sub _error_thrower { + my $self = shift; + require Moose::Meta::Class; + ( ref $self && $self->associated_metaclass ) || "Moose::Meta::Class"; +} + +sub throw_error { + my $self = shift; + my $inv = $self->_error_thrower; + unshift @_, "message" if @_ % 2 == 1; + unshift @_, method => $self if ref $self; + unshift @_, $inv; + my $handler = $inv->can("throw_error"); + goto $handler; # to avoid incrementing depth by 1 +} + +sub _inline_throw_error { + my ( $self, $msg, $args ) = @_; + + my $inv = $self->_error_thrower; + # XXX ugh + $inv = 'Moose::Meta::Class' unless $inv->can('_inline_throw_error'); + + # XXX ugh ugh UGH + my $class = $self->associated_metaclass; + if ($class) { + my $class_name = B::perlstring($class->name); + my $meth_name = B::perlstring($self->name); + $args = 'method => Class::MOP::class_of(' . $class_name . ')' + . '->find_method_by_name(' . $meth_name . '), ' + . (defined $args ? $args : ''); + } + + return $inv->_inline_throw_error($msg, $args) +} + 1; +# ABSTRACT: A Moose Method metaclass + __END__ =pod -=head1 NAME - -Moose::Meta::Method - A Moose Method metaclass - =head1 DESCRIPTION -For now, this is nothing but a subclass of Class::MOP::Method, -but with the expanding role of the method sub-protocol, it might -be more useful later on. +This class is a subclass of L that provides +additional Moose-specific functionality, all of which is private. -=head1 BUGS +To understand this class, you should read the the L +documentation. -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. +=head1 INHERITANCE -=head1 AUTHOR +C is a subclass of L. -Stevan Little Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2006-2008 by Infinity Interactive, Inc. - -L +=head1 BUGS -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +See L for details on reporting bugs. =cut