a few more Moose Type related fixes and added diag to the replication test to report...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Replicated / Types.pm
CommitLineData
dcdf7b2c 1package # hide from PAUSE
2 DBIx::Class::Storage::DBI::Replicated::Types;
3
998373c2 4# DBIx::Class::Storage::DBI::Replicated::Types - Types used internally by
5# L<DBIx::Class::Storage::DBI::Replicated>
9901aad7 6
7use MooseX::Types
6a151f58 8 -declare => [qw/BalancerClassNamePart Weight DBICSchema DBICStorageDBI/];
ee356d00 9use MooseX::Types::Moose qw/ClassName Str Num/;
9901aad7 10
11class_type 'DBIx::Class::Storage::DBI';
41916570 12class_type 'DBIx::Class::Schema';
9901aad7 13
6a151f58 14subtype DBICSchema, as 'DBIx::Class::Schema';
15subtype DBICStorageDBI, as 'DBIx::Class::Storage::DBI';
16
9901aad7 17subtype BalancerClassNamePart,
18 as ClassName;
998373c2 19
9901aad7 20coerce BalancerClassNamePart,
21 from Str,
22 via {
23 my $type = $_;
24 if($type=~m/^::/) {
25 $type = 'DBIx::Class::Storage::DBI::Replicated::Balancer'.$type;
998373c2 26 }
27 Class::MOP::load_class($type);
28 $type;
9901aad7 29 };
30
ee356d00 31subtype Weight,
32 as Num,
b88b85e7 33 where { $_ >= 0 },
34 message { 'weight must be a decimal greater than 0' };
ee356d00 35
998373c2 36# AUTHOR
37#
38# John Napiorkowski <john.napiorkowski@takkle.com>
39#
40# LICENSE
41#
42# You may distribute this code under the same terms as Perl itself.
dcdf7b2c 43
9901aad7 441;