annotate Lib/IMPL/ORM/Schema/Relation/HasOne.pm @ 45:1b1fb9d54f55

Starting web-application concept
author Sergey
date Fri, 29 Jan 2010 16:19:31 +0300
parents 6d33f75c6e1f
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
1 package IMPL::ORM::Schema::Relation::HasOne;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
2 use strict;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
3 use warnings;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
4
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
5 use base qw(IMPL::ORM::Schema::Relation);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
6 use IMPL::Class::Property;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
7
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
8 BEGIN {
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
9 public property target => prop_get | owner_set;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
10 public property name => prop_get | owner_set;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
11 }
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
12
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
13 our %CTOR = (
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
14 'IMPL::ORM::Schema::Relation' => sub { 'HasOne' }
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
15 );
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
16
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
17 sub CTOR {
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
18 my ($this,$name,$target) = @_;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
19 $this->name($name) or die new IMPL::InvalidArgumentException('A name is required for this relation');
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
20 $this->target($target) or die new IMPL::InvalidArgumentException('A target is required for this relation',$name);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
21 }
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
22
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
23 sub canHaveChildren {
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
24 0;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
25 }
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
26
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
27
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
28 1;