Revision history for Perl extension DBIx::Class::Schema::Loader
+ - generate POD for additional_classes, additional_base_classes,
+ left_base_classes, components, result_components_map,
+ result_roles and result_roles_map
- rename result_component_map to result_components_map (old name still
works)
- fix accessor collision detection for methods from
$self->classes->{$table} = $table_class;
$self->monikers->{$table} = $table_moniker;
+ $self->_pod_class_list($table_class, 'ADDITIONAL CLASSES USED', @{$self->additional_classes});
+
$self->_use ($table_class, @{$self->additional_classes});
+
+ $self->_pod_class_list($table_class, 'LEFT BASE CLASSES', @{$self->left_base_classes});
+
$self->_inject($table_class, @{$self->left_base_classes});
my @components = @{ $self->components || [] };
push @components, @{ $self->result_components_map->{$table_moniker} }
if exists $self->result_components_map->{$table_moniker};
+ my @fq_components = @components;
+ foreach my $component (@fq_components) {
+ if ($component !~ s/^\+//) {
+ $component = "DBIx::Class::$component";
+ }
+ }
+
+ $self->_pod_class_list($table_class, 'COMPONENTS LOADED', @fq_components);
+
$self->_dbic_stmt($table_class, 'load_components', @components) if @components;
+ $self->_pod_class_list($table_class, 'ADDITIONAL BASE CLASSES', @{$self->additional_base_classes});
+
$self->_inject($table_class, @{$self->additional_base_classes});
}
push @roles, @{ $self->result_roles_map->{$table_moniker} }
if exists $self->result_roles_map->{$table_moniker};
- $self->_with($table_class, @roles) if @roles;
+ if (@roles) {
+ $self->_pod_class_list($table_class, 'L<Moose> ROLES APPLIED', @roles);
+
+ $self->_with($table_class, @roles);
+ }
}
# Overload these in driver class:
}
}
+sub _pod_class_list {
+ my ($self, $class, $title, @classes) = @_;
+
+ return unless @classes && $self->generate_pod;
+
+ $self->_pod($class, "=head1 $title");
+ $self->_pod($class, '=over 4');
+
+ foreach my $link (@classes) {
+ $self->_pod($class, "=item L<$link>");
+ }
+
+ $self->_pod($class, '=back');
+ $self->_pod_cut($class);
+}
+
sub _filter_comment {
my ($self, $txt) = @_;
custom_column_info => sub {
my ($table, $col, $info) = @_;
return +{ extra => { is_footext => 1 } } if $col eq 'footext';
- }
+ },
+ additional_classes => 'TestAdditional',
+ additional_base_classes => 'TestAdditionalBase',
+ left_base_classes => 'TestLeftBase',
+ components => [ 'TestComponent', '+TestComponentFQN' ],
},
warnings => [
qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
],
Foo => [
qr/package DBICTest::DumpMore::1::Foo;/,
- qr/=head1 NAME\n\nDBICTest::DumpMore::1::Foo\n\n=cut\n\n/,
- qr/=head1 ACCESSORS\n\n/,
- qr/=head2 fooid\n\n data_type: 'integer'\n is_auto_increment: 1\n is_nullable: 0\n\n/,
- qr/=head2 footext\n\n data_type: 'text'\n default_value: 'footext'\n extra: {is_footext => 1}\n is_nullable: 1\n\n/,
+ qr/\n=head1 NAME\n\nDBICTest::DumpMore::1::Foo\n\n=cut\n\n/,
+ qr/\n=head1 ADDITIONAL CLASSES USED\n\n=over 4\n\n=item L<TestAdditional>\n\n=back\n\n=cut\n\n/,
+ qr/\n=head1 ADDITIONAL BASE CLASSES\n\n=over 4\n\n=item L<TestAdditionalBase>\n\n=back\n\n=cut\n\n/,
+ qr/\n=head1 LEFT BASE CLASSES\n\n=over 4\n\n=item L<TestLeftBase>\n\n=back\n\n=cut\n\n/,
+ qr/\n=head1 COMPONENTS LOADED\n\n=over 4\n\n=item L<DBIx::Class::TestComponent>\n\n=item L<TestComponentFQN>\n\n=back\n\n=cut\n\n/,
+ qr/\n=head1 ACCESSORS\n\n/,
+ qr/\n=head2 fooid\n\n data_type: 'integer'\n is_auto_increment: 1\n is_nullable: 0\n\n/,
+ qr/\n=head2 footext\n\n data_type: 'text'\n default_value: 'footext'\n extra: {is_footext => 1}\n is_nullable: 1\n\n/,
qr/->set_primary_key/,
- qr/=head1 RELATIONS\n\n/,
- qr/=head2 bars\n\nType: has_many\n\nRelated object: L<DBICTest::DumpMore::1::Bar>\n\n=cut\n\n/,
+ qr/\n=head1 RELATIONS\n\n/,
+ qr/\n=head2 bars\n\nType: has_many\n\nRelated object: L<DBICTest::DumpMore::1::Bar>\n\n=cut\n\n/,
qr/1;\n$/,
],
Bar => [
qr/package DBICTest::DumpMore::1::Bar;/,
- qr/=head1 NAME\n\nDBICTest::DumpMore::1::Bar\n\n=cut\n\n/,
- qr/=head1 ACCESSORS\n\n/,
- qr/=head2 barid\n\n data_type: 'integer'\n is_auto_increment: 1\n is_nullable: 0\n\n/,
- qr/=head2 fooref\n\n data_type: 'integer'\n is_foreign_key: 1\n is_nullable: 1\n\n/,
+ qr/\n=head1 NAME\n\nDBICTest::DumpMore::1::Bar\n\n=cut\n\n/,
+ qr/\n=head1 ADDITIONAL CLASSES USED\n\n=over 4\n\n=item L<TestAdditional>\n\n=back\n\n=cut\n\n/,
+ qr/\n=head1 ADDITIONAL BASE CLASSES\n\n=over 4\n\n=item L<TestAdditionalBase>\n\n=back\n\n=cut\n\n/,
+ qr/\n=head1 LEFT BASE CLASSES\n\n=over 4\n\n=item L<TestLeftBase>\n\n=back\n\n=cut\n\n/,
+ qr/\n=head1 COMPONENTS LOADED\n\n=over 4\n\n=item L<DBIx::Class::TestComponent>\n\n=item L<TestComponentFQN>\n\n=back\n\n=cut\n\n/,
+ qr/\n=head1 ACCESSORS\n\n/,
+ qr/\n=head2 barid\n\n data_type: 'integer'\n is_auto_increment: 1\n is_nullable: 0\n\n/,
+ qr/\n=head2 fooref\n\n data_type: 'integer'\n is_foreign_key: 1\n is_nullable: 1\n\n/,
qr/->set_primary_key/,
- qr/=head1 RELATIONS\n\n/,
- qr/=head2 fooref\n\nType: belongs_to\n\nRelated object: L<DBICTest::DumpMore::1::Foo>\n\n=cut\n\n/,
- qr/1;\n$/,
+ qr/\n=head1 RELATIONS\n\n/,
+ qr/\n=head2 fooref\n\nType: belongs_to\n\nRelated object: L<DBICTest::DumpMore::1::Foo>\n\n=cut\n\n/,
+ qr/\n1;\n$/,
],
},
);
use_moose => 1,
result_base_class => 'My::ResultBaseClass',
schema_base_class => 'My::SchemaBaseClass',
+ result_roles => ['TestRole', 'TestRole2'],
},
warnings => [
qr/Dumping manual schema for DBICTest::DumpMore::1 to directory /,
],
Foo => [
qr/\nuse Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;\nextends 'My::ResultBaseClass';\n\n/,
+ qr/=head1 L<Moose> ROLES APPLIED\n\n=over 4\n\n=item L<TestRole>\n\n=item L<TestRole2>\n\n=back\n\n=cut\n\n/,
+ qr/\nwith 'TestRole', 'TestRole2';\n\n/,
qr/\n__PACKAGE__->meta->make_immutable;\n1;(?!\n1;\n)\n.*/,
],
Bar => [
qr/\nuse Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;\nextends 'My::ResultBaseClass';\n\n/,
+ qr/=head1 L<Moose> ROLES APPLIED\n\n=over 4\n\n=item L<TestRole>\n\n=item L<TestRole2>\n\n=back\n\n=cut\n\n/,
+ qr/\nwith 'TestRole', 'TestRole2';\n\n/,
qr/\n__PACKAGE__->meta->make_immutable;\n1;(?!\n1;\n)\n.*/,
],
},
--- /dev/null
+package TestRole2;
+
+use Moose::Role;
+
+sub test_role2_method { 'test_role2_method works' }
+
+1;