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 | |
7 | use MooseX::Types |
ee356d00 |
8 | -declare => [qw/BalancerClassNamePart Weight/]; |
9 | use MooseX::Types::Moose qw/ClassName Str Num/; |
9901aad7 |
10 | |
11 | class_type 'DBIx::Class::Storage::DBI'; |
41916570 |
12 | class_type 'DBIx::Class::Schema'; |
9901aad7 |
13 | |
14 | subtype BalancerClassNamePart, |
15 | as ClassName; |
998373c2 |
16 | |
9901aad7 |
17 | coerce BalancerClassNamePart, |
18 | from Str, |
19 | via { |
20 | my $type = $_; |
21 | if($type=~m/^::/) { |
22 | $type = 'DBIx::Class::Storage::DBI::Replicated::Balancer'.$type; |
998373c2 |
23 | } |
24 | Class::MOP::load_class($type); |
25 | $type; |
9901aad7 |
26 | }; |
27 | |
ee356d00 |
28 | subtype Weight, |
29 | as Num, |
b88b85e7 |
30 | where { $_ >= 0 }, |
31 | message { 'weight must be a decimal greater than 0' }; |
ee356d00 |
32 | |
998373c2 |
33 | # AUTHOR |
34 | # |
35 | # John Napiorkowski <john.napiorkowski@takkle.com> |
36 | # |
37 | # LICENSE |
38 | # |
39 | # You may distribute this code under the same terms as Perl itself. |
dcdf7b2c |
40 | |
9901aad7 |
41 | 1; |