Commit | Line | Data |
dcdf7b2c |
1 | package # 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 | |
5292b35a |
7 | use warnings; |
8 | use strict; |
9 | |
1e1cc55e |
10 | use Type::Library |
11 | -base, |
12 | -declare => qw/BalancerClassNamePart Weight DBICSchema DBICStorageDBI/; |
13 | use Type::Utils -all; |
14 | use Types::Standard qw/Str Num/; |
15 | use Types::LoadableClass qw/LoadableClass/; |
9901aad7 |
16 | |
1e1cc55e |
17 | class_type DBICSchema, { class => 'DBIx::Class::Schema' }; |
18 | class_type DBICStorageDBI, { class => 'DBIx::Class::Storage::DBI' }; |
6a151f58 |
19 | |
9901aad7 |
20 | subtype BalancerClassNamePart, |
d401ab6b |
21 | as LoadableClass; |
998373c2 |
22 | |
9901aad7 |
23 | coerce BalancerClassNamePart, |
24 | from Str, |
25 | via { |
26 | my $type = $_; |
d401ab6b |
27 | $type =~ s/\A::/DBIx::Class::Storage::DBI::Replicated::Balancer::/; |
998373c2 |
28 | $type; |
9901aad7 |
29 | }; |
30 | |
ee356d00 |
31 | subtype Weight, |
32 | as Num, |
b88b85e7 |
33 | where { $_ >= 0 }, |
34 | message { 'weight must be a decimal greater than 0' }; |
ee356d00 |
35 | |
9901aad7 |
36 | 1; |