monotonic (and others) now pass
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / WithReasonableDefaults.pm
CommitLineData
41219a5d 1package DBIx::Class::DeploymentHandler::WithReasonableDefaults;
2use Moose::Role;
3
9deabd1f 4# ABSTRACT: Make default arguments to a few methods sensible
5
41219a5d 6requires qw( prepare_upgrade prepare_downgrade database_version schema_version );
7
4a65f60b 8around prepare_upgrade => sub {
41219a5d 9 my $orig = shift;
10 my $self = shift;
11
12 my $from_version = shift || $self->database_version;
13 my $to_version = shift || $self->schema_version;
14 my $version_set = shift || [$from_version, $to_version];
15
16 $self->$orig($from_version, $to_version, $version_set);
17};
18
19
4a65f60b 20around prepare_downgrade => sub {
21 my $orig = shift;
22 my $self = shift;
23
24 my $from_version = shift || $self->database_version;
25 my $to_version = shift || $self->schema_version;
48c3a562 26 my $version_set = shift || [$from_version, $to_version];
4a65f60b 27
28 $self->$orig($from_version, $to_version, $version_set);
29};
30
c8a2f7bd 31around install_resultsource => sub {
32 my $orig = shift;
33 my $self = shift;
34 my $source = shift;
35 my $version = shift || $self->to_version;
36
37 $self->$orig($source, $version);
38};
4a65f60b 39
41219a5d 401;
41
42__END__
43
44vim: ts=2 sw=2 expandtab
feca70da 45
46=head1 CONVENIENCE
47
48The whole point of this role is to set defaults for arguments of various
49methods. It's a little awesome.
50
51=head1 METHODS
52
53=head2 prepare_upgrade
54
55Defaulted args:
56
57 my $from_version = $self->database_version;
58 my $to_version = $self->schema_version;
59 my $version_set = [$from_version, $to_version];
60
61=head2 prepare_downgrade
62
63Defaulted args:
64
65 my $from_version = $self->database_version;
66 my $to_version = $self->schema_version;
48c3a562 67 my $version_set = [$to_version];
feca70da 68
69=head2 install_resultsource
70
71Defaulted args:
72
73 my $version = $self->to_version;