comparison _test/Test/ORM/Schema.pm @ 28:6d33f75c6e1f

ORM in works
author Sergey
date Mon, 19 Oct 2009 04:13:54 +0400
parents
children dd4d72600c69
comparison
equal deleted inserted replaced
27:b544a772b654 28:6d33f75c6e1f
1 package Test::ORM::Schema;
2 use strict;
3 use warnings;
4
5 require Exporter;
6 our @ISA = qw(Exporter);
7 our @EXPORT_OK = qw();
8
9 package Test::ORM::Schema::Data::User;
10 use base qw(IMPL::ORM::Object);
11 use IMPL::Class::Property;
12
13 BEGIN {
14 public property Name => prop_all, { type => 'String' }; # Field
15 public property Id => prop_all, { type => 'String' }; # Field
16 public property Roles => prop_all | prop_list, { type=> 'Test::ORM::Schema::Data::Role'}; # HasMany
17 }
18
19 package Test::ORM::Schema::Data::Role;
20 use base qw(IMPL::ORM::Object);
21 use IMPL::Class::Property;
22
23 BEGIN {
24 public property Name => prop_all, { type => 'String' }; # Field
25 }
26
27 package Test::ORM::Schema::Data::Session;
28 use base qw(IMPL::ORM::Object);
29 use IMPL::Class::Property;
30 use IMPL::ORM::Helpers qw(Map);
31
32 BEGIN {
33 public property Id => prop_get, { type => 'String' }; # Field
34 public property User => prop_get, { type => 'Test::ORM::Schema::Data::User' }; # HasOne
35 public property Data => prop_all, { type => Map( 'String','String' ) }; # HasOne
36 public property AccessTime => prop_get { type => 'DateTime' }; # Field
37 }
38
39 package Test::ORM::Schema::Data;
40 use base qw(IMPL::ORM::Schema);
41
42 __PACKAGE__->usePrefix(__PACKAGE__);
43 __PACKAGE__->Classes qw(
44 User
45 Role
46 Session
47 );
48
49 __PACKAGE__->ValueTypes (
50 'String' => 'IMPL::ORM::Value::String',
51 'DateTime' => 'IMPL::ORM::Value::DateTime',
52 'Integer' => 'IMPL::ORM::Value::Inetger',
53 'Float' => 'IMPL::ORM::Value::Float',
54 'Decimal' => 'IMPL::ORM::Value::Decimal'
55 );
56
57 1;