| 1 | package Smolder::DB::ProjectDeveloper; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use base 'Smolder::DB'; | ||
| 5 | |||
| 6 | __PACKAGE__->set_up_table('project_developer'); | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Smolder::DB::ProjectDeveloper | ||
| 11 | |||
| 12 | =head1 DESCRIPTION | ||
| 13 | |||
| 14 | L<Class::DBI> based model class for the 'project_developer' table in the database. | ||
| 15 | |||
| 16 | =head1 METHODS | ||
| 17 | |||
| 18 | =head2 ACCESSSOR/MUTATORS | ||
| 19 | |||
| 20 | Each column in the borough table has a method with the same name | ||
| 21 | that can be used as an accessor and mutator. | ||
| 22 | |||
| 23 | The following columns will return objects instead of the value contained in the table: | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | __PACKAGE__->has_a(project => 'Smolder::DB::Project'); | ||
| 28 | __PACKAGE__->has_a(developer => 'Smolder::DB::Developer'); | ||
| 29 | __PACKAGE__->has_a(preference => 'Smolder::DB::Preference'); | ||
| 30 | __PACKAGE__->has_a( | ||
| 31 | added => 'DateTime', | ||
| 32 | inflate => sub { __PACKAGE__->parse_datetime(shift) }, | ||
| 33 | deflate => sub { __PACKAGE__->format_datetime(shift) }, | ||
| 34 | ); | ||
| 35 | |||
| 36 | # make sure we delete any preferences that are attached to us | ||
| 37 | __PACKAGE__->add_trigger( | ||
| 38 | after_delete => sub { | ||
| 39 | my $self = shift; | ||
| 40 | my $pref = $self->preference; | ||
| 41 | $pref->delete if $pref; | ||
| 42 | } | ||
| 43 | ); | ||
| 44 | |||
| 45 | # make sure added is set to NOW | ||
| 46 | __PACKAGE__->add_trigger( | ||
| 47 | before_create => sub { | ||
| 48 | my $self = shift; | ||
| 49 | $self->_attribute_set(added => DateTime->now()); | ||
| 50 | }, | ||
| 51 | ); | ||
| 52 | |||
| 53 | =over | ||
| 54 | |||
| 55 | =item project | ||
| 56 | |||
| 57 | This is the L<Smolder::DB::Project> object to which this developer belongs. | ||
| 58 | |||
| 59 | =item developer | ||
| 60 | |||
| 61 | This is the L<Smolder::DB::Developer> object that belongs to this project. | ||
| 62 | |||
| 63 | =item preference | ||
| 64 | |||
| 65 | This is the L<Smolder::DB::Preference> object that belongs to this Developer for this Project. | ||
| 66 | When the object is created it starts out as a copy of the Developer's default Preference. | ||
| 67 | |||
| 68 | =item added | ||
| 69 | |||
| 70 | This is a L<DateTime> object for when the Developer was added to the Project. | ||
| 71 | |||
| 72 | =back | ||
| 73 | |||
| 74 | =cut | ||
| 75 | |||
| 76 | 1; |