X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FTypes.pm;fp=lib%2FMooseX%2FTypes.pm;h=4516728b91dfa4c381b819b31022308f843e2ac9;hb=6cfbfdbc099ddc95835bfb05384d36c9eba7e527;hp=6e18cd177ca70bf3f749adaa70beb95629985635;hpb=76cd1d7f79f3f6315c38a0b90d2fa9c717237cd1;p=gitmo%2FMooseX-Types.git diff --git a/lib/MooseX/Types.pm b/lib/MooseX/Types.pm index 6e18cd1..4516728 100644 --- a/lib/MooseX/Types.pm +++ b/lib/MooseX/Types.pm @@ -35,6 +35,7 @@ my $UndefMsg = q{Action for type '%s' not yet defined in library '%s'}; PositiveInt NegativeInt ArrayRefOfPositiveInt ArrayRefOfAtLeastThreeNegativeInts LotsOfInnerConstraints StrOrArrayRef + MyDateTime )]; # import builtin types @@ -73,9 +74,15 @@ my $UndefMsg = q{Action for type '%s' not yet defined in library '%s'}; subtype StrOrArrayRef, as Str|ArrayRef; + # class types + class_type 'DateTime'; - coerce 'DateTime', + # or better + + class_type MyDateTime, { class => 'DateTime' }; + + coerce MyDateTime, from HashRef, via { DateTime->new(%$_) }; @@ -420,7 +427,7 @@ it with @args. sub create_arged_type_constraint { my ($class, $name, @args) = @_; my $type_constraint = Moose::Util::TypeConstraints::find_or_create_type_constraint("$name"); - return $type_constraint->parameterize(@args); + return $type_constraint->parameterize(@args); } =head2 create_base_type_constraint ($name)