| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Rose::Planter::ConventionManager; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | =head1 NAME | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | Rose::Planter::ConventionManager - some handy convention defaults | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | This is a subclass of Rose::DB::Object::ConventionManager with | 
| 10 |  |  |  |  |  |  | a few tweaks. | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =head1 METHODS | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | =cut | 
| 15 |  |  |  |  |  |  |  | 
| 16 | 1 |  |  | 1 |  | 3228 | use base 'Rose::DB::Object::ConventionManager'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 645 |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | use strict; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | =head2 auto_relationship_name_one_to_many | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | By default if "foo_params" is a child of a table "foo", | 
| 23 |  |  |  |  |  |  | we remove the the "foo_" portion from "foo_params". | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | i.e.  If this table has only _one_ foreign key and the table name | 
| 26 |  |  |  |  |  |  | referred to in the foreign key is a prefix of this table name plus | 
| 27 |  |  |  |  |  |  | an underscore, then remove the table name and the underscore.  Got it? | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | =cut | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | sub auto_relationship_name_one_to_many { | 
| 32 |  |  |  |  |  |  | my $self = shift; | 
| 33 |  |  |  |  |  |  | my ($table,$class) = @_; | 
| 34 |  |  |  |  |  |  | my $name = $self->SUPER::auto_relationship_name_one_to_many(@_); | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | my @fks = $class->meta->foreign_keys; | 
| 37 |  |  |  |  |  |  | return $name unless @fks==1; | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | my $target = $fks[0]->class->meta->table; | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | $name =~ s/^$target\_//; | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | return $name; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | 1; | 
| 47 |  |  |  |  |  |  |  |