From: gfx Date: Mon, 8 Mar 2010 07:36:10 +0000 (+0900) Subject: Set correct parents for enum_type and duck_type X-Git-Tag: 0.50_08~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=188ff28f6755dfecb63b4bd16c4cb063d0c57ac6;p=gitmo%2FMouse.git Set correct parents for enum_type and duck_type --- diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index 3915dc7..7073a4d 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -227,7 +227,8 @@ sub duck_type { @methods = (@_ == 1 && ref($_[0]) eq 'ARRAY') ? @{$_[0]} : @_; # DuckType - return _create_type 'type', $name => ( + return _create_type 'subtype', $name => ( + as => 'Object', optimized_as => Mouse::Util::generate_can_predicate_for(\@methods), ); } @@ -242,7 +243,8 @@ sub enum { %valid = map{ $_ => undef } (@_ == 1 && ref($_[0]) eq 'ARRAY' ? @{$_[0]} : @_); # EnumType - return _create_type 'type', $name => ( + return _create_type 'subtype', $name => ( + as => 'Str', optimized_as => sub{ defined($_[0]) && !ref($_[0]) && exists $valid{$_[0]} }, ); }