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 | # Workaround for https://rt.cpan.org/Public/Bug/Display.html?id=83336 |
8 | use warnings; |
9 | use strict; |
10 | |
9901aad7 |
11 | use MooseX::Types |
6a151f58 |
12 | -declare => [qw/BalancerClassNamePart Weight DBICSchema DBICStorageDBI/]; |
ee356d00 |
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 | |
6a151f58 |
18 | subtype DBICSchema, as 'DBIx::Class::Schema'; |
19 | subtype DBICStorageDBI, as 'DBIx::Class::Storage::DBI'; |
20 | |
9901aad7 |
21 | subtype BalancerClassNamePart, |
22 | as ClassName; |
998373c2 |
23 | |
9901aad7 |
24 | coerce BalancerClassNamePart, |
25 | from Str, |
26 | via { |
27 | my $type = $_; |
28 | if($type=~m/^::/) { |
29 | $type = 'DBIx::Class::Storage::DBI::Replicated::Balancer'.$type; |
998373c2 |
30 | } |
31 | Class::MOP::load_class($type); |
32 | $type; |
9901aad7 |
33 | }; |
34 | |
ee356d00 |
35 | subtype Weight, |
36 | as Num, |
b88b85e7 |
37 | where { $_ >= 0 }, |
38 | message { 'weight must be a decimal greater than 0' }; |
ee356d00 |
39 | |
998373c2 |
40 | # AUTHOR |
41 | # |
42 | # John Napiorkowski <john.napiorkowski@takkle.com> |
43 | # |
44 | # LICENSE |
45 | # |
46 | # You may distribute this code under the same terms as Perl itself. |
dcdf7b2c |
47 | |
9901aad7 |
48 | 1; |