From: Arthur Axel 'fREW' Schmidt Date: Sat, 8 May 2010 05:50:19 +0000 (-0500) Subject: no more role-delegates! X-Git-Tag: v0.001000_07~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1b7ebcbf973fff1903fbddba8fda41990bf8ec65;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git no more role-delegates! --- diff --git a/lib/DBIx/Class/DeploymentHandler/Deprecated.pm b/lib/DBIx/Class/DeploymentHandler/Deprecated.pm index 57520cc..b361628 100644 --- a/lib/DBIx/Class/DeploymentHandler/Deprecated.pm +++ b/lib/DBIx/Class/DeploymentHandler/Deprecated.pm @@ -8,8 +8,19 @@ use Moose::Util 'apply_all_roles'; extends 'DBIx::Class::DeploymentHandler::Dad'; # a single with would be better, but we can't do that # see: http://rt.cpan.org/Public/Bug/Display.html?id=46347 -with 'DBIx::Class::DeploymentHandler::Deprecated::WithDeprecatedSqltDeployMethod', - 'DBIx::Class::DeploymentHandler::Deprecated::WithDeprecatedVersionStorage'; +with 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { + interface_role => 'DBIx::Class::DeploymentHandler::HandlesDeploy', + class_name => 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated', + delegate_name => 'deploy_method', + attributes_to_assume => ['schema'], + attributes_to_copy => [qw( upgrade_directory databases sql_translator_args )], + }, + 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { + interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage', + class_name => 'DBIx::Class::DeploymentHandler::VersionStorage::Deprecated', + delegate_name => 'version_storage', + attributes_to_assume => ['schema'], + }; with 'DBIx::Class::DeploymentHandler::WithReasonableDefaults'; sub BUILD { @@ -18,14 +29,27 @@ sub BUILD { if ($self->schema->can('ordered_versions') && $self->schema->ordered_versions) { apply_all_roles( $self, - 'DBIx::Class::DeploymentHandler::WithExplicitVersions' + 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { + interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersioning', + class_name => 'DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions', + delegate_name => 'version_handler', + attributes_to_assume => [qw( database_version schema_version to_version )], + } ); } else { apply_all_roles( $self, - 'DBIx::Class::DeploymentHandler::WithDatabaseToSchemaVersions' + 'DBIx::Class::DeploymentHandler::WithApplicatorDumple' => { + interface_role => 'DBIx::Class::DeploymentHandler::HandlesVersioning', + class_name => 'DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions', + delegate_name => 'version_handler', + attributes_to_assume => [qw( database_version schema_version to_version )], + } ); } + # the following is just a hack so that ->version_storage + # won't be lazy + $self->version_storage; } __PACKAGE__->meta->make_immutable; diff --git a/lib/DBIx/Class/DeploymentHandler/Deprecated/WithDeprecatedSqltDeployMethod.pm b/lib/DBIx/Class/DeploymentHandler/Deprecated/WithDeprecatedSqltDeployMethod.pm deleted file mode 100644 index 2eba6a1..0000000 --- a/lib/DBIx/Class/DeploymentHandler/Deprecated/WithDeprecatedSqltDeployMethod.pm +++ /dev/null @@ -1,62 +0,0 @@ -package DBIx::Class::DeploymentHandler::Deprecated::WithDeprecatedSqltDeployMethod; -use Moose::Role; - -# ABSTRACT: (DEPRECATED) Use this if you are stuck in the past - -use DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated; - -has deploy_method => ( - does => 'DBIx::Class::DeploymentHandler::HandlesDeploy', - is => 'ro', - lazy_build => 1, - handles => 'DBIx::Class::DeploymentHandler::HandlesDeploy', -); - -has upgrade_directory => ( - isa => 'Str', - is => 'ro', - required => 1, - default => 'sql', -); - -has databases => ( - coerce => 1, - isa => 'DBIx::Class::DeploymentHandler::Databases', - is => 'ro', - default => sub { [qw( MySQL SQLite PostgreSQL )] }, -); - -has sql_translator_args => ( - isa => 'HashRef', - is => 'ro', - default => sub { {} }, -); - -sub _build_deploy_method { - my $self = shift; - DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated->new({ - schema => $self->schema, - databases => $self->databases, - upgrade_directory => $self->upgrade_directory, - sql_translator_args => $self->sql_translator_args, - }); -} - -1; - -# vim: ts=2 sw=2 expandtab - -__END__ - -=head1 DEPRECATED - -This component has been suplanted by -L. -In the next major version (1) we will begin issuing a warning on it's use. -In the major version after that (2) we will remove it entirely. - -=head1 DELEGATION ROLE - -This role is entirely for making delegation look like a role. The actual -docs for the methods and attributes are at -L diff --git a/lib/DBIx/Class/DeploymentHandler/Deprecated/WithDeprecatedVersionStorage.pm b/lib/DBIx/Class/DeploymentHandler/Deprecated/WithDeprecatedVersionStorage.pm deleted file mode 100644 index 0ce6227..0000000 --- a/lib/DBIx/Class/DeploymentHandler/Deprecated/WithDeprecatedVersionStorage.pm +++ /dev/null @@ -1,37 +0,0 @@ -package DBIx::Class::DeploymentHandler::Deprecated::WithDeprecatedVersionStorage; -use Moose::Role; - -# ABSTRACT: (DEPRECATED) Use this if you are stuck in the past - -use DBIx::Class::DeploymentHandler::VersionStorage::Deprecated; - -has version_storage => ( - does => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage', - is => 'ro', - builder => '_build_version_storage', - handles => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage', -); - -sub _build_version_storage { - DBIx::Class::DeploymentHandler::VersionStorage::Deprecated - ->new({ schema => $_[0]->schema }); -} - -1; - -# vim: ts=2 sw=2 expandtab - -__END__ - -=head1 DEPRECATED - -This component has been suplanted by -L. -In the next major version (1) we will begin issuing a warning on it's use. -In the major version after that (2) we will remove it entirely. - -=head1 DELEGATION ROLE - -This role is entirely for making delegation look like a role. The actual -docs for the methods and attributes are at -L diff --git a/lib/DBIx/Class/DeploymentHandler/WithApplicatorDumple.pm b/lib/DBIx/Class/DeploymentHandler/WithApplicatorDumple.pm index cb6f573..107780b 100644 --- a/lib/DBIx/Class/DeploymentHandler/WithApplicatorDumple.pm +++ b/lib/DBIx/Class/DeploymentHandler/WithApplicatorDumple.pm @@ -3,6 +3,13 @@ use MooseX::Role::Parameterized; use Class::MOP; use namespace::autoclean; +# this is at least a little ghetto and not super well +# thought out. Take a look at the following at some +# point to clean it all up: +# +# http://search.cpan.org/~jjnapiork/MooseX-Role-BuildInstanceOf-0.06/lib/MooseX/Role/BuildInstanceOf.pm +# http://github.com/rjbs/role-subsystem/blob/master/lib/Role/Subsystem.pm + parameter interface_role => ( isa => 'Str', required => 1, @@ -38,7 +45,7 @@ role { my $meta = Class::MOP::class_of($class_name); has $_->name => %{ $_->clone } - for grep { $_ } map $meta->get_attribute($_), @{ $p->attributes_to_copy }; + for grep { $_ } map $meta->find_attribute_by_name($_), @{ $p->attributes_to_copy }; has $p->delegate_name => ( is => 'ro', diff --git a/lib/DBIx/Class/DeploymentHandler/WithDatabaseToSchemaVersions.pm b/lib/DBIx/Class/DeploymentHandler/WithDatabaseToSchemaVersions.pm deleted file mode 100644 index 2b33d6a..0000000 --- a/lib/DBIx/Class/DeploymentHandler/WithDatabaseToSchemaVersions.pm +++ /dev/null @@ -1,39 +0,0 @@ -package DBIx::Class::DeploymentHandler::WithDatabaseToSchemaVersions; -use Moose::Role; - -# ABSTRACT: Delegate/Role for DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions - -use DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions; - -use Carp 'carp'; - -has version_handler => ( - is => 'ro', - lazy_build => 1, - does => 'DBIx::Class::DeploymentHandler::HandlesVersioning', - handles => 'DBIx::Class::DeploymentHandler::HandlesVersioning', -); - -sub _build_version_handler { - my $self = shift; - - my $args = { - database_version => $self->database_version, - schema_version => $self->schema_version, - }; - - $args->{to_version} = $self->to_version if $self->has_to_version; - DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new($args); -} - -1; - -# vim: ts=2 sw=2 expandtab - -__END__ - -=head1 DELEGATION ROLE - -This role is entirely for making delegation look like a role. The actual -docs for the methods and attributes are at -L diff --git a/lib/DBIx/Class/DeploymentHandler/WithExplicitVersions.pm b/lib/DBIx/Class/DeploymentHandler/WithExplicitVersions.pm deleted file mode 100644 index 4861960..0000000 --- a/lib/DBIx/Class/DeploymentHandler/WithExplicitVersions.pm +++ /dev/null @@ -1,39 +0,0 @@ -package DBIx::Class::DeploymentHandler::WithExplicitVersions; -use Moose::Role; - -# ABSTRACT: Delegate/Role for DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions - -use DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions; - -use Carp 'carp'; - -has version_handler => ( - is => 'ro', - lazy_build => 1, - does => 'DBIx::Class::DeploymentHandler::HandlesVersioning', - handles => 'DBIx::Class::DeploymentHandler::HandlesVersioning', -); - -sub _build_version_handler { - my $self = shift; - - my $args = { - database_version => $self->database_version, - schema_version => $self->schema_version, - }; - - $args->{to_version} = $self->to_version if $self->has_to_version; - DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions->new($args); -} - -1; - -# vim: ts=2 sw=2 expandtab - -__END__ - -=head1 DELEGATION ROLE - -This role is entirely for making delegation look like a role. The actual -docs for the methods and attributes are at -L diff --git a/lib/DBIx/Class/DeploymentHandler/WithSqltDeployMethod.pm b/lib/DBIx/Class/DeploymentHandler/WithSqltDeployMethod.pm deleted file mode 100644 index 9ff8417..0000000 --- a/lib/DBIx/Class/DeploymentHandler/WithSqltDeployMethod.pm +++ /dev/null @@ -1,58 +0,0 @@ -package DBIx::Class::DeploymentHandler::WithSqltDeployMethod; -use Moose::Role; - -# ABSTRACT: Delegate/Role for DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator - -use DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator; - -has deploy_method => ( - does => 'DBIx::Class::DeploymentHandler::HandlesDeploy', - is => 'ro', - lazy_build => 1, - handles => 'DBIx::Class::DeploymentHandler::HandlesDeploy', -); - -has upgrade_directory => ( - isa => 'Str', - is => 'ro', - required => 1, - default => 'sql', -); - -has databases => ( - coerce => 1, - isa => 'DBIx::Class::DeploymentHandler::Databases', - is => 'ro', - default => sub { [qw( MySQL SQLite PostgreSQL )] }, -); - -has sql_translator_args => ( - isa => 'HashRef', - is => 'ro', - default => sub { {} }, -); - -sub _build_deploy_method { - my $self = shift; - my $args = { - schema => $self->schema, - databases => $self->databases, - upgrade_directory => $self->upgrade_directory, - sql_translator_args => $self->sql_translator_args, - }; - - $args->{schema_version} = $self->schema_version if $self->has_schema_version; - DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator->new($args); -} - -1; - -# vim: ts=2 sw=2 expandtab - -__END__ - -=head1 DELEGATION ROLE - -This role is entirely for making delegation look like a role. The actual -docs for the methods and attributes are at -L