From: Yuval Kogman Date: Wed, 24 May 2006 19:42:33 +0000 (+0000) Subject: Make prototypes of various decls (requires, with, extends) accept qw// form, not... X-Git-Tag: 0_09_03~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=68117c4523857f230ceac0f36db4187a951d315c;p=gitmo%2FMoose.git Make prototypes of various decls (requires, with, extends) accept qw// form, not just "foo", "bar" form --- diff --git a/lib/Moose.pm b/lib/Moose.pm index 7756cb4..c0f882d 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -68,7 +68,8 @@ use Moose::Util::TypeConstraints; my %exports = ( extends => sub { my $class = $CALLER; - return subname 'Moose::extends' => sub ($;@) { + return subname 'Moose::extends' => sub (@) { + confess "Must derive at least one class" unless @_; _load_all_classes(@_); my $meta = $class->meta; foreach my $super (@_) { @@ -106,8 +107,9 @@ use Moose::Util::TypeConstraints; }, with => sub { my $class = $CALLER; - return subname 'Moose::with' => sub ($;@) { + return subname 'Moose::with' => sub (@) { my (@roles) = @_; + confess "Must specify at least one role" unless @roles; _load_all_classes(@roles); ($_->can('meta') && $_->meta->isa('Moose::Meta::Role')) || confess "You can only consume roles, $_ is not a Moose role" diff --git a/lib/Moose/Role.pm b/lib/Moose/Role.pm index af0b25c..9fe4461 100644 --- a/lib/Moose/Role.pm +++ b/lib/Moose/Role.pm @@ -53,8 +53,9 @@ use Moose::Util::TypeConstraints; }, with => sub { my $meta = _find_meta(); - return subname 'Moose::Role::with' => sub ($;@) { + return subname 'Moose::Role::with' => sub (@) { my (@roles) = @_; + confess "Must specify at least one role" unless @roles; Moose::_load_all_classes(@roles); ($_->can('meta') && $_->meta->isa('Moose::Meta::Role')) || confess "You can only consume roles, $_ is not a Moose role" @@ -71,13 +72,15 @@ use Moose::Util::TypeConstraints; }, requires => sub { my $meta = _find_meta(); - return subname 'Moose::Role::requires' => sub ($;@) { + return subname 'Moose::Role::requires' => sub (@) { + confess "Must specify at least one method" unless @_; $meta->add_required_methods(@_); }; }, excludes => sub { my $meta = _find_meta(); - return subname 'Moose::Role::excludes' => sub ($;@) { + return subname 'Moose::Role::excludes' => sub (@) { + confess "Must specify at least one role" unless @_; $meta->add_excluded_roles(@_); }; }, @@ -290,4 +293,4 @@ L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=cut \ No newline at end of file +=cut