summaryrefslogtreecommitdiffstats
path: root/lib/WWW/Unfuddle/Meta/Types.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-06-16 22:23:03 -0500
committerJesse Luehrs <doy@tozt.net>2009-06-16 22:23:03 -0500
commit3f8cbe6bf3bf305c9bb77d8f15b1ad2143ee440a (patch)
tree397713a3aef10a0615a2d74fda07819c6c9303ed /lib/WWW/Unfuddle/Meta/Types.pm
parentafcde73887075e3befd4bf35815ee0f757b093b6 (diff)
downloadwww-unfuddle-3f8cbe6bf3bf305c9bb77d8f15b1ad2143ee440a.tar.gz
www-unfuddle-3f8cbe6bf3bf305c9bb77d8f15b1ad2143ee440a.zip
split type constraints out into a type lib, with proper coercionsHEADmaster
Diffstat (limited to 'lib/WWW/Unfuddle/Meta/Types.pm')
-rw-r--r--lib/WWW/Unfuddle/Meta/Types.pm20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/WWW/Unfuddle/Meta/Types.pm b/lib/WWW/Unfuddle/Meta/Types.pm
new file mode 100644
index 0000000..344a231
--- /dev/null
+++ b/lib/WWW/Unfuddle/Meta/Types.pm
@@ -0,0 +1,20 @@
+package WWW::Unfuddle::Meta::Types;
+use Moose::Util::TypeConstraints;
+use DateTime::Format::ISO8601;
+use JSON;
+
+class_type 'JSON::Boolean';
+subtype 'WWW::Unfuddle::Bool', as 'Bool', where { !ref($_) };
+coerce 'WWW::Unfuddle::Bool', from 'JSON::Boolean',
+ via { $_ == JSON::true };
+
+# 2009-06-16T22:55:06Z
+class_type 'DateTime';
+subtype 'WWW::Unfuddle::DateTime', as 'DateTime';
+coerce 'WWW::Unfuddle::DateTime', from 'Str',
+ via { DateTime::Format::ISO8601->new->parse_datetime($_) };
+
+enum 'WWW::Unfuddle::Assignee' => qw(reporter none nochange);
+enum 'WWW::Unfuddle::ThemeColor' => qw(blue green grey orange purple red teal);
+
+1;