X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FRelBuilder.pm;h=06edf335297a8773a02e808dac911633afbe71ba;hb=4c7b5f46aba56cb71d6e15ad4034c780bf01e809;hp=a20fe16c93eef5882c8e77174e2b4be443d765f7;hpb=289496709ffe36f6e233811ec3f4b28b8dc1bc5f;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm index a20fe16..06edf33 100644 --- a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm +++ b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm @@ -26,15 +26,7 @@ is module is not (yet) for external use. =head2 new -Arguments: schema_class (scalar), inflect_plural, inflect_singular - -C<$schema_class> should be a schema class name, where the source -classes have already been set up and registered. Column info, primary -key, and unique constraints will be drawn from this schema for all -of the existing source monikers. - -Options inflect_plural and inflect_singular are optional, and are better documented -in L. +Arguments: $base object =head2 generate_code @@ -76,19 +68,32 @@ arguments, like so: =cut + sub new { - my ( $class, $schema, $inflect_pl, $inflect_singular, $rel_attrs ) = @_; + my ( $class, $base ) = @_; + + # from old POD about this constructor: + # C<$schema_class> should be a schema class name, where the source + # classes have already been set up and registered. Column info, + # primary key, and unique constraints will be drawn from this + # schema for all of the existing source monikers. + + # Options inflect_plural and inflect_singular are optional, and + # are better documented in L. my $self = { - schema => $schema, - inflect_plural => $inflect_pl, - inflect_singular => $inflect_singular, - relationship_attrs => $rel_attrs, + base => $base, + schema => $base->schema, + inflect_plural => $base->inflect_plural, + inflect_singular => $base->inflect_singular, + relationship_attrs => $base->relationship_attrs, }; + Scalar::Util::weaken $self->{base}; #< don't leak + # validate the relationship_attrs arg if( defined $self->{relationship_attrs} ) { - ref($self->{relationship_attrs}) eq 'HASH' + ref $self->{relationship_attrs} eq 'HASH' or croak "relationship_attrs must be a hashref"; }