From: Peter Rabbitson Date: Wed, 4 Jan 2012 09:56:44 +0000 (+0100) Subject: Drop Class::Accessor::Fast in favor of Moo X-Git-Tag: v0.11011~52 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9023f08fcf2357fcc5e6f11407b873ceacae2890;p=dbsrgits%2FSQL-Translator.git Drop Class::Accessor::Fast in favor of Moo --- diff --git a/Changes b/Changes index 43daaf0..afbae7c 100644 --- a/Changes +++ b/Changes @@ -17,6 +17,7 @@ * MySQL producer does not attempt to write out non-existent unique constraint names * MySQL parser correctly differentiates between signed and unsigned integer column display sizes +* Replace Class::Accessor::Fast dependency with already-included Moo # ---------------------------------------------------------- # 0.11010 2011-10-05 diff --git a/Makefile.PL b/Makefile.PL index c16164c..2f90fe0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -16,7 +16,6 @@ my $deps = { 'IO::Scalar' => 2.110, 'Parse::RecDescent' => 1.962002, 'Pod::Usage' => 0, - 'Class::Accessor::Fast' => 0, 'DBI' => 0, 'File::ShareDir' => 1.0, 'File::Spec' => 0, diff --git a/lib/SQL/Translator/Diff.pm b/lib/SQL/Translator/Diff.pm index 423c256..9d9e493 100644 --- a/lib/SQL/Translator/Diff.pm +++ b/lib/SQL/Translator/Diff.pm @@ -8,15 +8,59 @@ use warnings; use Data::Dumper; use Carp::Clan qw/^SQL::Translator/; use SQL::Translator::Schema::Constants; - -use base 'Class::Accessor::Fast'; - -# Input/option accessors -__PACKAGE__->mk_accessors(qw/ - ignore_index_names ignore_constraint_names ignore_view_sql - ignore_proc_sql output_db source_schema target_schema - case_insensitive no_batch_alters ignore_missing_methods producer_args -/); +use Sub::Quote qw(quote_sub); +use Moo; + +has ignore_index_names => ( + is => 'rw', +); +has ignore_constraint_names => ( + is => 'rw', +); +has ignore_view_sql => ( + is => 'rw', +); +has ignore_proc_sql => ( + is => 'rw', +); +has output_db => ( + is => 'rw', +); +has source_schema => ( + is => 'rw', +); +has target_schema => ( + is => 'rw', +); +has case_insensitive => ( + is => 'rw', +); +has no_batch_alters => ( + is => 'rw', +); +has ignore_missing_methods => ( + is => 'rw', +); +has producer_args => ( + is => 'rw', + lazy => 1, + default => quote_sub '{}', +); +has tables_to_drop => ( + is => 'rw', + lazy => 1, + default => quote_sub '[]', +); +has tables_to_create => ( + is => 'rw', + lazy => 1, + default => quote_sub '[]', +); +has table_diff_hash => ( + is => 'rw', + lazy => 1, + default => quote_sub '{}', +); my @diff_arrays = qw/ tables_to_drop @@ -36,8 +80,6 @@ my @diff_hash_keys = qw/ table_renamed_from /; -__PACKAGE__->mk_accessors(@diff_arrays, 'table_diff_hash'); - sub schema_diff { # use Data::Dumper; ## we are getting instructions on how to turn the source into the target @@ -59,18 +101,19 @@ sub schema_diff { $obj->compute_differences->produce_diff_sql; } -sub new { - my ($class, $values) = @_; - $values->{$_} ||= [] foreach @diff_arrays; - $values->{table_diff_hash} = {}; - - $values->{producer_args} ||= {}; - if ($values->{producer_options}) { +sub BUILD { + my ($self, $args) = @_; + if ($args->{producer_options}) { carp 'producer_options is deprecated. Please use producer_args'; - $values->{producer_args} = { %{$values->{producer_options}}, %{$values->{producer_args}} }; + $self->producer_args({ + %{$args->{producer_options}}, + %{$self->producer_args} + }); + } + + if (! $self->output_db) { + $self->output_db($args->{source_db}) } - $values->{output_db} ||= $values->{source_db}; - return $class->SUPER::new($values); } sub compute_differences {