Mercurial > pub > Impl
comparison Lib/IMPL/SQL/Schema/Column.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 |
comparison
equal
deleted
inserted
replaced
164:eb3e9861a761 | 165:76515373dac0 |
---|---|
1 use strict; | 1 use strict; |
2 package IMPL::SQL::Schema::Column; | 2 package IMPL::SQL::Schema::Column; |
3 use base qw(IMPL::Object IMPL::Object::Autofill IMPL::Object::Clonable); | 3 use parent qw(IMPL::Object IMPL::Object::Autofill); |
4 | 4 |
5 use IMPL::Class::Property; | 5 use IMPL::Class::Property; |
6 use IMPL::Class::Property::Direct; | 6 use IMPL::Class::Property::Direct; |
7 | 7 |
8 BEGIN { | 8 BEGIN { |
9 public _direct property Name => prop_get; | 9 public _direct property name => prop_get; |
10 public _direct property Type => prop_get; | 10 public _direct property type => prop_get; |
11 public _direct property CanBeNull => prop_get; | 11 public _direct property isNullable => prop_get; |
12 public _direct property DefaultValue => prop_get; | 12 public _direct property defaultValue => prop_get; |
13 public _direct property Tag => prop_get; | 13 public _direct property tag => prop_get; |
14 } | 14 } |
15 | 15 |
16 __PACKAGE__->PassThroughArgs; | 16 __PACKAGE__->PassThroughArgs; |
17 | 17 |
18 sub CTOR { | 18 sub CTOR { |
19 my $this = shift; | 19 my $this = shift; |
20 | 20 |
21 $this->{$Name} or die new IMPL::InvalidArgumentException('a column name is required'); | 21 $this->{$name} or die new IMPL::InvalidArgumentException('a column name is required'); |
22 $this->{$CanBeNull} = 0 if not exists $this->{$CanBeNull}; | 22 $this->{$isNullable} = 0 if not exists $this->{$isNullable}; |
23 UNIVERSAL::isa($this->{$Type},'IMPL::SQL::Schema::Type') or die new IMPL::InvalidArgumentException('a type is required for the column',$this->{$Name}); | 23 UNIVERSAL::isa($this->{$type},'IMPL::SQL::Schema::Type') or die new IMPL::InvalidArgumentException('a type is required for the column',$this->{$name}); |
24 } | 24 } |
25 | 25 |
26 sub isEqualsStr { | 26 sub isEqualsStr { |
27 my ($a,$b) = @_; | 27 my ($a,$b) = @_; |
28 | 28 |
52 } | 52 } |
53 | 53 |
54 sub isSame { | 54 sub isSame { |
55 my ($this,$other) = @_; | 55 my ($this,$other) = @_; |
56 | 56 |
57 return ($this->{$Name} eq $other->{$Name} and $this->{$CanBeNull} == $other->{$CanBeNull} and isEqualsStr($this->{$DefaultValue}, $other->{$DefaultValue}) and $this->{$Type}->isSame($other->{$Type})); | 57 return ($this->{$name} eq $other->{$name} and $this->{$isNullable} == $other->{$isNullable} and isEqualsStr($this->{$defaultValue}, $other->{$defaultValue}) and $this->{$type}->isSame($other->{$type})); |
58 } | 58 } |
59 | 59 |
60 1; | 60 1; |