File Coverage

blib/lib/DBIx/Class/Schema/PopulateMore/Test/Schema/Result/CompanyPerson.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package #hide from pause
2             DBIx::Class::Schema::PopulateMore::Test::Schema::Result::CompanyPerson;
3              
4 3     3   8407 use parent 'DBIx::Class::Schema::PopulateMore::Test::Schema::Result';
  3         6  
  3         15  
5              
6             =head1 NAME
7              
8             DBIx::Class::Schema::PopulateMore::Test::Schema::Result::CompanyPerson - Bridge between Company and Person
9              
10             =head1 DESCRIPTION
11              
12             Bridge table for many to many style relationship between Company and Person.
13              
14             =head1 ATTRIBUTES
15              
16             This class defines the following attributes.
17              
18             =head1 PACKAGE METHODS
19              
20             This module defines the following package methods
21              
22             =head2 table
23              
24             Name of the Physical table in the database
25              
26             =cut
27              
28             __PACKAGE__
29             ->table('company_person');
30              
31              
32             =head2 add_columns
33              
34             Add columns and meta information
35              
36             =head3 fk_person_id
37              
38             ID of the person with a companies
39              
40             =head3 fk_company_id
41              
42             ID of the company with persons
43              
44             =cut
45              
46             __PACKAGE__
47             ->add_columns(
48             fk_person_id => {
49             data_type=>'integer',
50             },
51             fk_company_id => {
52             data_type=>'integer',
53             },
54             );
55            
56              
57             =head2 primary_key
58              
59             Sets the Primary keys for this table
60              
61             =cut
62              
63             __PACKAGE__
64             ->set_primary_key(qw/fk_person_id fk_company_id/);
65            
66              
67             =head2 employee
68              
69             The person that is employed by a company
70              
71             =cut
72              
73             __PACKAGE__
74             ->belongs_to( employee => 'DBIx::Class::Schema::PopulateMore::Test::Schema::Result::Person', {
75             'foreign.person_id' => 'self.fk_person_id' });
76              
77              
78             =head2 company
79              
80             The company that employees the person
81              
82             =cut
83              
84             __PACKAGE__
85             ->belongs_to( company => 'DBIx::Class::Schema::PopulateMore::Test::Schema::Result::Company', {
86             'foreign.company_id' => 'self.fk_company_id' });
87              
88              
89             =head2 employment_history
90              
91             each instance of a company_person has a related employment history
92              
93             =cut
94              
95             __PACKAGE__
96             ->has_one (employment_history => 'DBIx::Class::Schema::PopulateMore::Test::Schema::Result::EmploymentHistory', {
97             'foreign.fk_company_id' => 'self.fk_company_id',
98             'foreign.fk_person_id' => 'self.fk_person_id',
99             });
100              
101              
102             =head1 METHODS
103              
104             This module defines the following methods.
105              
106             =head1 AUTHOR
107              
108             Please see L<DBIx::Class::Schema::PopulateMore> For authorship information
109              
110             =head1 LICENSE
111              
112             Please see L<DBIx::Class::Schema::PopulateMore> For licensing terms.
113              
114             =cut
115              
116              
117             1;