X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FAdmin%2FTypes.pm;fp=lib%2FDBIx%2FClass%2FAdmin%2FTypes.pm;h=b3d46c7d9f4368a3bdf48c9a215ed5e7dd93769c;hb=a21416fa1c21a9ab74952c4740f18476ef37cafe;hp=c6f37c615057cb2234136a8afc91425ecdc0fde4;hpb=1e1cc55ea27a0f41b4f300b41de94e4d2f45d12d;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Admin/Types.pm b/lib/DBIx/Class/Admin/Types.pm index c6f37c6..b3d46c7 100644 --- a/lib/DBIx/Class/Admin/Types.pm +++ b/lib/DBIx/Class/Admin/Types.pm @@ -1,17 +1,26 @@ package # hide from PAUSE DBIx::Class::Admin::Types; -# Workaround for https://rt.cpan.org/Public/Bug/Display.html?id=83336 use warnings; use strict; -use MooseX::Types -declare => [qw( +use Type::Library + -base, + -declare => qw( + Dir File DBICConnectInfo DBICArrayRef DBICHashRef -)]; -use MooseX::Types::Moose qw/Int HashRef ArrayRef Str Any Bool/; -use MooseX::Types::JSON qw(JSON); +); +use Type::Utils -all; +use Types::Standard qw/HashRef ArrayRef Str/; +use Path::Class; + +class_type Dir, { class => 'Path::Class::Dir' }; +class_type File, { class => 'Path::Class::File' }; + +coerce Dir, from Str, via { dir($_) }; +coerce File, from Str, via { file($_) }; subtype DBICArrayRef, as ArrayRef; @@ -20,30 +29,23 @@ subtype DBICHashRef, as HashRef; coerce DBICArrayRef, - from JSON, + from Str, via { _json_to_data ($_) }; coerce DBICHashRef, - from JSON, + from Str, via { _json_to_data($_) }; subtype DBICConnectInfo, as ArrayRef; coerce DBICConnectInfo, - from JSON, - via { return _json_to_data($_) } ; - -coerce DBICConnectInfo, - from Str, - via { return _json_to_data($_) }; - -coerce DBICConnectInfo, - from HashRef, - via { [ $_ ] }; + from Str, via { _json_to_data($_) }, + from HashRef, via { [ $_ ] }; sub _json_to_data { my ($json_str) = @_; + require JSON::Any; my $json = JSON::Any->new(allow_barekey => 1, allow_singlequote => 1, relaxed=>1); my $ret = $json->jsonToObj($json_str); return $ret;