Commit | Line | Data |
62fa8aec |
1 | package #hide from pause |
2 | DBICNGTest::Schema::Result::Gender; |
3 | |
4 | use Moose; |
5 | extends 'DBICNGTest::Schema::Result'; |
6 | |
7 | |
8 | =head1 NAME |
9 | |
10 | DBICNGTest::Schema::Result::Gender; An example Gender Class; |
11 | |
12 | =head1 DESCRIPTION |
13 | |
14 | Tests for this type of FK relationship |
15 | |
16 | =head1 ATTRIBUTES |
17 | |
18 | This class defines the following attributes. |
19 | |
20 | =head2 label |
21 | |
22 | example of using an attribute to add constraints on a table insert |
23 | |
24 | =cut |
25 | |
26 | has 'label' =>(is=>'rw', required=>1, isa=>'Str'); |
27 | |
28 | |
29 | =head1 PACKAGE METHODS |
30 | |
31 | This module defines the following package methods |
32 | |
33 | =head2 table |
34 | |
35 | Name of the Physical table in the database |
36 | |
37 | =cut |
38 | |
39 | __PACKAGE__ |
40 | ->table('gender'); |
41 | |
42 | |
43 | =head2 add_columns |
44 | |
45 | Add columns and meta information |
46 | |
47 | =head3 gender_id |
48 | |
49 | Primary Key which is an auto generated UUID |
50 | |
51 | =head3 label |
52 | |
53 | Text label of the gender (ie, 'male', 'female', 'transgender', etc.). |
54 | |
55 | =cut |
56 | |
57 | __PACKAGE__ |
58 | ->add_columns( |
59 | gender_id => { |
60 | data_type=>'integer', |
61 | }, |
62 | label => { |
63 | data_type=>'varchar', |
64 | size=>12, |
65 | }, |
66 | ); |
67 | |
68 | |
69 | =head2 primary_key |
70 | |
71 | Sets the Primary keys for this table |
72 | |
73 | =cut |
74 | |
75 | __PACKAGE__ |
76 | ->set_primary_key(qw/gender_id/); |
77 | |
78 | |
79 | =head2 |
80 | |
81 | Marks the unique columns |
82 | |
83 | =cut |
84 | |
85 | __PACKAGE__ |
86 | ->add_unique_constraint('gender_label_unique' => [ qw/label/ ]); |
87 | |
88 | |
89 | =head2 people |
90 | |
91 | A resultset of people with this gender |
92 | |
93 | =cut |
94 | |
95 | __PACKAGE__ |
96 | ->has_many( |
97 | people => 'DBICNGTest::Schema::Result::Person', |
98 | {'foreign.fk_gender_id' => 'self.gender_id'} |
99 | ); |
100 | |
101 | |
102 | =head1 METHODS |
103 | |
104 | This module defines the following methods. |
105 | |
106 | =head1 AUTHORS |
107 | |
108 | See L<DBIx::Class> for more information regarding authors. |
109 | |
110 | =head1 LICENSE |
111 | |
112 | You may distribute this code under the same terms as Perl itself. |
113 | |
114 | =cut |
115 | |
116 | |
117 | 1; |