Commit | Line | Data |
62fa8aec |
1 | package #hide from pause |
2 | DBICNGTest::Schema::Result::FriendList; |
3 | |
4 | use Moose; |
5 | extends 'DBICNGTest::Schema::Result'; |
6 | |
7 | |
8 | =head1 NAME |
9 | |
10 | Zoomwit::tlib::DBIC::Schema::Result::FriendList; An example Friends Class; |
11 | |
12 | =head1 VERSION |
13 | |
14 | 0.01 |
15 | |
16 | =cut |
17 | |
18 | our $VERSION = '0.01'; |
19 | |
20 | |
21 | =head1 DESCRIPTION |
22 | |
23 | A Person can have zero or more friends |
24 | A Person can't be their own friend |
25 | A Person over 18 can't be friends with Persons under 18 and vis versa. |
26 | A Person can have friendships that are not mutual. |
27 | |
28 | =head1 ATTRIBUTES |
29 | |
30 | This class defines the following attributes. |
31 | |
32 | =head1 PACKAGE METHODS |
33 | |
34 | This module defines the following package methods |
35 | |
36 | =head2 table |
37 | |
38 | Name of the Physical table in the database |
39 | |
40 | =cut |
41 | |
42 | __PACKAGE__ |
43 | ->table('friend_list'); |
44 | |
45 | |
46 | =head2 add_columns |
47 | |
48 | Add columns and meta information |
49 | |
50 | =head3 fk_person_id |
51 | |
52 | ID of the person with friends |
53 | |
54 | =head3 fk_friend_id |
55 | |
56 | Who is the friend? |
57 | |
58 | =cut |
59 | |
60 | __PACKAGE__ |
61 | ->add_columns( |
62 | fk_person_id => { |
63 | data_type=>'integer', |
64 | }, |
65 | fk_friend_id => { |
66 | data_type=>'integer', |
67 | }, |
68 | ); |
69 | |
70 | |
71 | =head2 primary_key |
72 | |
73 | Sets the Primary keys for this table |
74 | |
75 | =cut |
76 | |
77 | __PACKAGE__ |
78 | ->set_primary_key(qw/fk_person_id fk_friend_id/); |
79 | |
80 | |
81 | =head2 befriender |
82 | |
83 | The person that 'owns' the friendship (list) |
84 | |
85 | =cut |
86 | |
87 | __PACKAGE__ |
88 | ->belongs_to( befriender => 'DBICNGTest::Schema::Result::Person', { |
89 | 'foreign.person_id' => 'self.fk_person_id' }); |
90 | |
91 | |
92 | =head2 friendee |
93 | |
94 | The actual friend that befriender is listing |
95 | |
96 | =cut |
97 | |
98 | __PACKAGE__ |
99 | ->belongs_to( friendee => 'DBICNGTest::Schema::Result::Person', { |
100 | 'foreign.person_id' => 'self.fk_friend_id' }); |
101 | |
102 | |
103 | =head1 METHODS |
104 | |
105 | This module defines the following methods. |
106 | |
107 | =head1 AUTHORS |
108 | |
109 | See L<DBIx::Class> for more information regarding authors. |
110 | |
111 | =head1 LICENSE |
112 | |
113 | You may distribute this code under the same terms as Perl itself. |
114 | |
115 | =cut |
116 | |
117 | |
118 | 1; |