[Bps-public-commit] r17528 - in Net-Google-Code/trunk: lib/Net/Google/Code

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Jan 2 02:35:25 EST 2009


Author: sunnavy
Date: Fri Jan  2 02:35:24 2009
New Revision: 17528

Modified:
   Net-Google-Code/trunk/   (props changed)
   Net-Google-Code/trunk/lib/Net/Google/Code/Search.pm

Log:
 r18486 at sunnavys-mb:  sunnavy | 2009-01-02 15:33:10 +0800
 refacotr _can part, limit its value


Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Search.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Search.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Search.pm	Fri Jan  2 02:35:24 2009
@@ -2,6 +2,7 @@
 use Moose;
 use Params::Validate qw(:all);
 use Net::Google::Code::Ticket;
+use Moose::Util::TypeConstraints;
 
 has connection => (
     isa => 'Net::Google::Code::Connection',
@@ -9,16 +10,20 @@
     required => 1,
 );
 
-#our %CAN = (
-#    'all'    => 1,
-#    'open'   => 2,
-#    'new'    => 6,
-#    'verify' => 7,
-#);
+our %CAN = (
+    'all'    => 1,
+    'open'   => 2,
+    'new'    => 6,
+    'verify' => 7,
+);
+
+subtype 'Can' => as 'Int' => where { my $v = $_; grep { $_ eq $v } values %CAN };
+subtype 'CanStr' => as 'Str' => where { $CAN{$_} };
+coerce 'Can' => from 'CanStr' => via { $CAN{$_} };
 
 has '_can' => (
     is  => 'rw',
-    isa => 'Int',
+    isa => 'Can',
     default => 2,
 );
 



More information about the Bps-public-commit mailing list