minor replication changes - use a real hash merge, clarify master_read_weight, really...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Replicated / Types.pm
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
10
11 use MooseX::Types
12   -declare => [qw/BalancerClassNamePart Weight/];
13 use MooseX::Types::Moose qw/ClassName Str Num/;
14
15 class_type 'DBIx::Class::Storage::DBI';
16 class_type 'DBIx::Class::Schema';
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
32 subtype Weight,
33   as Num,
34   where { $_ >= 0 },
35   message { 'weight must be a decimal greater than 0' };
36
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
47 1;