Mercurial > pub > Impl
diff Lib/IMPL/SQL/Schema/Constraint.pm @ 165:76515373dac0
Added Class::Template,
Rewritten SQL::Schema
'use parent' directive instead of 'use base'
author | wizard |
---|---|
date | Sat, 23 Apr 2011 23:06:48 +0400 |
parents | 6ce1f052b90a |
children | 1f7a6d762394 |
line wrap: on
line diff
--- a/Lib/IMPL/SQL/Schema/Constraint.pm Mon Mar 28 01:36:24 2011 +0400 +++ b/Lib/IMPL/SQL/Schema/Constraint.pm Sat Apr 23 23:06:48 2011 +0400 @@ -1,31 +1,31 @@ use strict; package IMPL::SQL::Schema::Constraint; -use base qw(IMPL::Object IMPL::Object::Disposable IMPL::Object::Clonable); +use parent qw(IMPL::Object IMPL::Object::Disposable); use IMPL::Class::Property; use IMPL::Class::Property::Direct; BEGIN { - public _direct property Name => prop_get; - public _direct property Table => prop_get; - public _direct property Columns => prop_get; + public _direct property name => prop_get; + public _direct property table => prop_get; + public _direct property columns => prop_get; } sub CTOR { my ($this,%args) = @_; - die new IMPL::InvalidArgumentException("The table argument must be an instance of a table object") if not UNIVERSAL::isa($args{'Table'},'IMPL::SQL::Schema::Table'); - $this->{$Name} = $args{'Name'}; - $this->{$Table} = $args{'Table'}; - $this->{$Columns} = [map { ResolveColumn($this->Table,$_) } @{$args{'Columns'}}]; + die new IMPL::InvalidArgumentException("The table argument must be an instance of a table object") if not UNIVERSAL::isa($args{'table'},'IMPL::SQL::Schema::Table'); + $this->{$name} = $args{'name'}; + $this->{$table} = $args{'table'}; + $this->{$columns} = [map { ResolveColumn($this->table,$_) } @{$args{'columns'}}]; } sub ResolveColumn { my ($Table,$Column) = @_; - my $cn = UNIVERSAL::isa($Column,'IMPL::SQL::Schema::Column') ? $Column->Name : $Column; + my $cn = UNIVERSAL::isa($Column,'IMPL::SQL::Schema::Column') ? $Column->name : $Column; my $resolved = $Table->Column($cn); - die new IMPL::InvalidOperationException("The column is not found in the table", $cn, $Table->Name) if not $resolved; + die new IMPL::InvalidOperationException("The column is not found in the table", $cn, $Table->name) if not $resolved; return $resolved; } @@ -34,18 +34,18 @@ my %Columns = map { $_, 1} @Columns; - return scalar(grep { $Columns{$_->Name} } @{$this->Columns}) == scalar(@Columns); + return scalar(grep { $Columns{$_->name} } @{$this->columns}) == scalar(@Columns); } -sub UniqName { +sub uniqName { my ($this) = @_; - return $this->{$Table}->Name.'_'.$this->{$Name}; + return $this->{$table}->name.'_'.$this->{$name}; } sub Dispose { my ($this) = @_; - delete @$this{$Table,$Columns}; + delete @$this{$table,$columns}; $this->SUPER::Dispose; } 1;