if ($self->naming->{relationships} eq 'v4') {
require DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040;
return $self->{relbuilder} ||=
- DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040->new(
- $self->schema,
- $self->inflect_plural,
- $self->inflect_singular,
- $self->relationship_attrs,
- );
+ DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040->new( $self );
}
elsif ($self->naming->{relationships} eq 'v5') {
require DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05;
- return $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05->new (
- $self->schema,
- $self->inflect_plural,
- $self->inflect_singular,
- $self->relationship_attrs,
- );
+ return $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05->new( $self );
}
elsif ($self->naming->{relationships} eq 'v6') {
require DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06;
- return $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06->new (
- $self->schema,
- $self->inflect_plural,
- $self->inflect_singular,
- $self->relationship_attrs,
- );
+ return $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_06->new( $self );
}
- return $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder->new (
- $self->schema,
- $self->inflect_plural,
- $self->inflect_singular,
- $self->relationship_attrs,
- );
+ return $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder->new ( $self );
}
sub _load_tables {
=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<DBIx::Class::Schema::Loader::Base>.
+Arguments: $base object
=head2 generate_code
=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<DBIx::Class::Schema::Loader::Base>.
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";
}