Commit | Line | Data |
dcdf7b2c |
1 | package # hide from PAUSE |
2 | DBIx::Class::Storage::DBI::Replicated::Types; |
3 | |
4 | =head1 NAME |
5 | |
6 | DBIx::Class::Storage::DBI::Replicated::Types - Types used internally by |
7 | L<DBIx::Class::Storage::DBI::Replicated> |
8 | |
9 | =cut |
9901aad7 |
10 | |
11 | use MooseX::Types |
ee356d00 |
12 | -declare => [qw/BalancerClassNamePart Weight/]; |
13 | use MooseX::Types::Moose qw/ClassName Str Num/; |
9901aad7 |
14 | |
15 | class_type 'DBIx::Class::Storage::DBI'; |
41916570 |
16 | class_type 'DBIx::Class::Schema'; |
9901aad7 |
17 | |
18 | subtype BalancerClassNamePart, |
19 | as ClassName; |
20 | |
21 | coerce BalancerClassNamePart, |
22 | from Str, |
23 | via { |
24 | my $type = $_; |
25 | if($type=~m/^::/) { |
26 | $type = 'DBIx::Class::Storage::DBI::Replicated::Balancer'.$type; |
27 | } |
28 | Class::MOP::load_class($type); |
29 | $type; |
30 | }; |
31 | |
ee356d00 |
32 | subtype Weight, |
33 | as Num, |
34 | where { $_ >= 0 && $_ <= 1 }, |
35 | message { 'weight must be a decimal between 0 and 1' }; |
36 | |
dcdf7b2c |
37 | =head1 AUTHOR |
38 | |
39 | John Napiorkowski <john.napiorkowski@takkle.com> |
40 | |
41 | =head1 LICENSE |
42 | |
43 | You may distribute this code under the same terms as Perl itself. |
44 | |
45 | =cut |
46 | |
9901aad7 |
47 | 1; |