X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FUtil%2FTypeConstraints.pm;fp=lib%2FMoose%2FUtil%2FTypeConstraints.pm;h=14185862f27652de9d77647b537204826e69f8ed;hb=d3a8251db802e3458285e09e4db12fd6d9d0b1b6;hp=b44a0eb89d3ebeb7be44792b65b84afa10045d2c;hpb=7d24db9289ff608fb713ac0e699422a4e36f4d42;p=gitmo%2FMoose.git diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index b44a0eb..1418586 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -5,6 +5,7 @@ use Carp (); use List::MoreUtils qw( all any ); use Scalar::Util qw( blessed reftype ); use Moose::Exporter; +use Moose::Deprecated; ## -------------------------------------------------------- # Prototyped subs must be predeclared because we have a @@ -377,12 +378,19 @@ sub maybe_type { sub duck_type { my ( $type_name, @methods ) = @_; if ( ref $type_name eq 'ARRAY' && !@methods ) { - @methods = @$type_name; + @methods = ($type_name); $type_name = undef; } if ( @methods == 1 && ref $methods[0] eq 'ARRAY' ) { @methods = @{ $methods[0] }; } + else { + Moose::Deprecated::deprecated( + feature => 'non-arrayref form of duck_type', + message => "Passing a list of values to duck_type is deprecated. " + . "The method names should be wrapped in an arrayref.", + ); + } register_type_constraint( create_duck_type_constraint( @@ -430,12 +438,19 @@ sub enum { @values == 0 || __PACKAGE__->_throw_error("enum called with an array reference and additional arguments. Did you mean to parenthesize the enum call's parameters?"); - @values = @$type_name; + @values = ($type_name); $type_name = undef; } if ( @values == 1 && ref $values[0] eq 'ARRAY' ) { @values = @{ $values[0] }; } + else { + Moose::Deprecated::deprecated( + feature => 'non-arrayref form of enum', + message => "Passing a list of values to enum is deprecated. " + . "Enum values should be wrapped in an arrayref.", + ); + } register_type_constraint( create_enum_type_constraint(