Mercurial > pub > Impl
diff Lib/IMPL/SQL/Schema/Traits/Diff.pm @ 315:77df11605d3a
code cleanup
author | cin |
---|---|
date | Tue, 07 May 2013 02:19:24 +0400 |
parents | 4d0e1962161c |
children |
line wrap: on
line diff
--- a/Lib/IMPL/SQL/Schema/Traits/Diff.pm Thu May 02 10:43:49 2013 +0400 +++ b/Lib/IMPL/SQL/Schema/Traits/Diff.pm Tue May 07 02:19:24 2013 +0400 @@ -1,13 +1,22 @@ package IMPL::SQL::Schema::Traits::Diff; use strict; use warnings; -use IMPL::lang qw(:compare :hash is); +use IMPL::lang qw(:compare :hash is typeof); use IMPL::SQL::Schema(); use IMPL::SQL::Schema::Traits(); +# defining a constant is a good style to enable compile checks use constant { - schema_t => typeof IMPL::SQL::Schema # defining a constant is a good style to enable compile checks + schema_t => 'IMPL::SQL::Schema', + ConstraintForeignKey => 'IMPL::SQL::Schema::Constraint::ForeignKey', + TraitsForeignKey => 'IMPL::SQL::Schema::Traits::ForeignKey', + ConstraintPrimaryKey => 'IMPL::SQL::Schema::Constraint::PrimaryKey', + TraitsPrimaryKey => 'IMPL::SQL::Schema::Traits::PrimaryKey', + ConstraintUnique => 'IMPL::SQL::Schema::Constraint::Unique', + TraitsUnique => 'IMPL::SQL::Schema::Traits::Unique', + ConstraintIndex => 'IMPL::SQL::Schema::Constraint::Index', + TraitsIndex => 'IMPL::SQL::Schema::Traits::Index' }; sub Diff { @@ -148,13 +157,13 @@ my ($constraint) = @_; my $map = { - typeof IMPL::SQL::Schema::Constraint::ForeignKey , typeof IMPL::SQL::Schema::Traits::ForeignKey, - typeof IMPL::SQL::Schema::Constraint::PrimaryKey , typeof IMPL::SQL::Schema::Traits::PrimaryKey, - typeof IMPL::SQL::Schema::Constraint::Unique , typeof IMPL::SQL::Schema::Traits::Unique, - typeof IMPL::SQL::Schema::Constraint::Index , typeof IMPL::SQL::Schema::Traits::Index + ConstraintForeignKey , TraitsForeignKey, + ConstraintPrimaryKey , TraitsPrimaryKey, + ConstraintUnique , TraitsUnique, + ConstraintIndex , TraitsIndex }; - my $class = $map->{$constraint->typeof} or die new IMPL::Exception("Can't map the constraint",$constraint->typeof); + my $class = $map->{typeof($constraint)} or die new IMPL::Exception("Can't map the constraint",typeof($constraint)); return $class->new( $constraint->name,