Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you just want to add a few methods, etc. to the parent class, your code should work. You might need to <code>use MooseX::NonMoose</code>, and in the past I have had the parent subclass <code>DBIx::Class::Core</code> instead of <code>DBIx::Class</code>. Here is what I've used successfully:</p> <pre><code># Parent package App::Schema::Result; use Moose; use MooseX::NonMoose; use namespace::autoclean; extends 'DBIx::Class::Core'; sub parent_method { ... } # Child package App::Schema::Result::Product; use Moose; use MooseX::NonMoose; use namespace::autoclean; extends 'Keystone::Schema::Site::Result'; __PACKAGE__-&gt;table('products'); sub child_method { my ($self) = @_; $self-&gt;parent_method(); } </code></pre> <p>If you want the parent class to define <code>DBIx::Class</code> specific information (ie, call <code>__PACKAGE-&gt;table</code>, <code>__PACKAGE__-&gt;add_columns</code>, etc) take a look at <code>DBIx::Class::Helper::Row::SubClass</code>. Using it, you define the parent class as you would a normal <code>DBIx::Class::Result::*</code> and in the child class use the <code>SubClass</code> component and call <code>subclass</code>:</p> <pre><code># Parent package App::Schema::Result::Parent; use Moose; use MooseX::NonMoose; extends 'DBIx::Class'; __PACKAGE__-&gt;load_components(qw{InflateColumn::DateTime Core}); __PACKAGE__-&gt;table('products'); ... # Child package App::Schema::Result::Child; use Moose; use MooseX::NonMoose; extends 'App::Schema::Result::Parent'; __PACKAGE__-&gt;load_components(qw{Helper::Row::SubClass Core}); __PACKAGE__-&gt;subclass; # Now add the child specific stuff / override parent stuff </code></pre> <p>I'm not sure if you can get <code>Loader</code> to auto-generate some of this code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload