49
+ − 1 package IMPL::ORM::Entity;
+ − 2 use strict;
+ − 3 use warnings;
+ − 4
+ − 5 use base qw(IMPL::Object);
+ − 6 use IMPL::Class::Property;
+ − 7 use IMPL::Class::Property::Direct;
+ − 8
+ − 9 BEGIN {
+ − 10 public _direct property Name => prop_get;
+ − 11 public _direct property Class => prop_get;
+ − 12 public _direct property Values => prop_get;
+ − 13 public _direct property Schema => prop_get;
+ − 14 }
+ − 15
+ − 16 sub CTOR {
+ − 17 my ($this,$class,$schema) = @_;
+ − 18
+ − 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 };
+ − 26 }
+ − 27
+ − 28 sub Store;
+ − 29 *Store = \&dbgStore;
+ − 30
+ − 31 sub dbgStore {
+ − 32 my ($this,$prop,$value) = @_;
+ − 33
+ − 34 if ( my $container = $this->{$Values}{$prop} ) {
+ − 35 $container->{oldValue} = $container->{value};
+ − 36 $container->{value} = $value;
+ − 37 } else {
+ − 38 die new IMPL::InvalidOperationException("Property not found",$this->Name,$prop);
+ − 39 }
+ − 40 }
+ − 41
+ − 42 sub Get {
+ − 43 my ($this,$prop) = @_;
+ − 44
+ − 45 return $this->{$Values}{$prop}{value};
+ − 46 }
+ − 47
+ − 48 1;