From: Gordon Irving Date: Wed, 20 Jan 2010 20:13:24 +0000 (+0000) Subject: add private types to coerce X-Git-Tag: v0.08119~9^2~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a62dec821b89925c9486f7a386a81d19a2e9e5f3;p=dbsrgits%2FDBIx-Class.git add private types to coerce --- diff --git a/lib/DBIx/Class/Admin.pm b/lib/DBIx/Class/Admin.pm index 862143f..234a5bc 100644 --- a/lib/DBIx/Class/Admin.pm +++ b/lib/DBIx/Class/Admin.pm @@ -25,8 +25,8 @@ use Moose; use parent 'DBIx::Class::Schema'; use Carp::Clan qw/^DBIx::Class/; -use MooseX::Types::Moose qw/Int HashRef ArrayRef Str Any Bool/; -use DBIx::Class::Admin::Types qw/DBICConnectInfo/; +use MooseX::Types::Moose qw/Int Str Any Bool/; +use DBIx::Class::Admin::Types qw/DBICConnectInfo DBICHashRef/; use MooseX::Types::JSON qw(JSON); use MooseX::Types::Path::Class qw(Dir File); use Try::Tiny; @@ -117,7 +117,7 @@ a hash ref or json string to be used for identifying data to manipulate has 'where' => ( is => 'rw', - isa => HashRef, + isa => DBICHashRef, coerce => 1, ); @@ -130,7 +130,7 @@ a hash ref or json string to be used for inserting or updating data has 'set' => ( is => 'rw', - isa => HashRef, + isa => DBICHashRef, coerce => 1, ); @@ -143,7 +143,7 @@ a hash ref or json string to be used for passing additonal info to the ->search has 'attrs' => ( is => 'rw', - isa => HashRef, + isa => DBICHashRef, coerce => 1, ); @@ -204,7 +204,7 @@ config_stanza will still be required. has config => ( is => 'ro', - isa => HashRef, + isa => DBICHashRef, lazy_build => 1, ); diff --git a/lib/DBIx/Class/Admin/Types.pm b/lib/DBIx/Class/Admin/Types.pm index 10a0a04..23af292 100644 --- a/lib/DBIx/Class/Admin/Types.pm +++ b/lib/DBIx/Class/Admin/Types.pm @@ -3,15 +3,23 @@ package # hide from PAUSE use MooseX::Types -declare => [qw( DBICConnectInfo + DBICArrayRef + DBICHashRef )]; use MooseX::Types::Moose qw/Int HashRef ArrayRef Str Any Bool/; use MooseX::Types::JSON qw(JSON); -coerce ArrayRef, +subtype DBICArrayRef, + as ArrayRef; + +subtype DBICHashRef, + as HashRef; + +coerce DBICArrayRef, from JSON, via { _json_to_data ($_) }; -coerce HashRef, +coerce DBICHashRef, from JSON, via { _json_to_data($_) };