comparison Lib/IMPL/ORM/Entity.pm @ 28:6d33f75c6e1f

ORM in works
author Sergey
date Mon, 19 Oct 2009 04:13:54 +0400
parents b544a772b654
children 16ada169ca75
comparison
equal deleted inserted replaced
27:b544a772b654 28:6d33f75c6e1f
14 } 14 }
15 15
16 sub CTOR { 16 sub CTOR {
17 my ($this,$class,$schema) = @_; 17 my ($this,$class,$schema) = @_;
18 18
19 19 $this->{$Class} = $class;
20 (my $name = $class) =~ s/::/_/g;
21 $this->{$Name} = $name;
22 $this->Schema = $schema;
23 $this->{$Values} = {
24 map {$_->{name},{type => $_->{type}, virtual => $_->{virtual}}} @$schema
25 };
20 } 26 }
21 27
22 sub Store; 28 sub Store;
23 *Store = \&dbgStore; 29 *Store = \&dbgStore;
24 30
25 sub dbgStore { 31 sub dbgStore {
26 my ($this,$prop,$value) = @_; 32 my ($this,$prop,$value) = @_;
27 33
28 if ( my $container = $this->{$Values}{$prop} ) { 34 if ( my $container = $this->{$Values}{$prop} ) {
29 if ($container->{type} eq 'SCALAR') { 35 $container->{oldValue} = $container->{value};
30 36 $container->{value} = $value;
31 } else {
32
33 }
34
35 } else { 37 } else {
36 die new IMPL::InvalidOperationException("Property not found",$this->Name,$prop); 38 die new IMPL::InvalidOperationException("Property not found",$this->Name,$prop);
37 } 39 }
38 } 40 }
39 41
40 sub Get { 42 sub Get {
43 my ($this,$prop) = @_;
41 44
45 return $this->{$Values}{$prop}{value};
42 } 46 }
43 47
44 1; 48 1;