Dagfinn Ilmari Mannsåker > DBIx-Class-Schema-Loader-0.04999_03 > DBIx::Class::Schema::Loader::RelBuilder

Download:
DBIx-Class-Schema-Loader-0.04999_03.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  17
Open  14
View Bugs
Report a bug
Module Version: 0.04999_03   Source   Latest Release: DBIx-Class-Schema-Loader-0.04999_10

NAME ^

DBIx::Class::Schema::Loader::RelBuilder - Builds relationships for DBIx::Class::Schema::Loader

SYNOPSIS ^

See DBIx::Class::Schema::Loader

DESCRIPTION ^

This class builds relationships for DBIx::Class::Schema::Loader. This is module is not (yet) for external use.

METHODS ^

new

Arguments: schema_class (scalar), inflect_plural, inflect_singular

$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 DBIx::Class::Schema::Loader::Base.

generate_code

Arguments: local_moniker (scalar), fk_info (arrayref)

This generates the code for the relationships of a given table.

local_moniker is the moniker name of the table which had the REFERENCES statements. The fk_info arrayref's contents should take the form:

    [
        {
            local_columns => [ 'col2', 'col3' ],
            remote_columns => [ 'col5', 'col7' ],
            remote_moniker => 'AnotherTableMoniker',
        },
        {
            local_columns => [ 'col1', 'col4' ],
            remote_columns => [ 'col1', 'col2' ],
            remote_moniker => 'YetAnotherTableMoniker',
        },
        # ...
    ],

This method will return the generated relationships as a hashref keyed on the class names. The values are arrayrefs of hashes containing method name and arguments, like so:

  {
      'Some::Source::Class' => [
          { method => 'belongs_to', arguments => [ 'col1', 'Another::Source::Class' ],
          { method => 'has_many', arguments => [ 'anothers', 'Yet::Another::Source::Class', 'col15' ],
      ],
      'Another::Source::Class' => [
          # ...
      ],
      # ...
  }