X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FDeploymentHandler%2FTypes.pm;h=eed11bdbe8d7d22140d968789e95822430c2555f;hb=a976d6e46695d7015239ee4c30cb3708f4ce7942;hp=2cefab6d32c7c2eab7f473be14821dd4c87b8b73;hpb=7ae4c20759f7cffd15912aec8784111ceb5543f2;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git diff --git a/lib/DBIx/Class/DeploymentHandler/Types.pm b/lib/DBIx/Class/DeploymentHandler/Types.pm index 2cefab6..eed11bd 100644 --- a/lib/DBIx/Class/DeploymentHandler/Types.pm +++ b/lib/DBIx/Class/DeploymentHandler/Types.pm @@ -4,23 +4,37 @@ use warnings; # ABSTRACT: Types internal to DBIx::Class::DeploymentHandler -use Moose::Util::TypeConstraints; -subtype 'DBIx::Class::DeploymentHandler::Databases' - => as 'ArrayRef[Str]'; - -coerce 'DBIx::Class::DeploymentHandler::Databases' - => from 'Str' - => via { [$_] }; - -subtype 'StrSchemaVersion' - => as 'Str' - => message { - defined $_ - ? "Schema version (currently '$_') must be a string" - : 'Schema version must be defined' - }; - -no Moose::Util::TypeConstraints; +use Sub::Quote 'quote_sub'; + +use Sub::Exporter -setup => { + exports => [ qw(Storage ResultSet StrSchemaVersion) ], +}; + +sub ResultSet { +quote_sub(q{ + use Check::ISA; + obj($_[0], 'DBIx::Class::ResultSet') + or die 'version_rs should be a DBIx::Class::ResultSet!' + }) +} + +sub Storage { +quote_sub(q{ + use Check::ISA; + obj($_[0], 'DBIx::Class::Storage') + or die 'storage should be a DBIx::Class::Storage!' + }) +} + +sub StrSchemaVersion { + quote_sub(q{ + die(defined $_[0] + ? "Schema version (currently '$_[0]') must be a string" + : 'Schema version must be defined' + ) unless ref(\$_[0]) eq 'SCALAR' + }) +} + 1; # vim: ts=2 sw=2 expandtab