From: Rafael Kitover Date: Thu, 20 Jan 2011 22:42:17 +0000 (-0500) Subject: remove MooseX::NonMoose from Schema files under use_moose=1 X-Git-Tag: 0.07003~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=49643e1dff62e16331c30f51953d548d94da1d30;p=dbsrgits%2FDBIx-Class-Schema-Loader.git remove MooseX::NonMoose from Schema files under use_moose=1 --- diff --git a/Changes b/Changes index d043869..4a8206e 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - remove MooseX::NonMoose from Schema files under use_moose=1 - better _tables_list for Sybase ASE - add datetime_undef_if_invalid => 1 for MySQL datetime data types (RT#64820) This behavior can be turned off by passing diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 66847c3..419b9ea 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -1220,7 +1220,7 @@ sub _dump_to_dir { . qq|# DO NOT MODIFY THE FIRST PART OF THIS FILE\n\n|; if ($self->use_moose) { - $schema_text.= qq|use Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;\nextends '$schema_base_class';\n\n|; + $schema_text.= qq|use Moose;\nuse namespace::autoclean;\nextends '$schema_base_class';\n\n|; } else { $schema_text .= qq|use strict;\nuse warnings;\n\nuse base '$schema_base_class';\n\n|; @@ -1343,7 +1343,7 @@ sub _write_classfile { } } - $custom_content ||= $self->_default_custom_content; + $custom_content ||= $self->_default_custom_content($is_schema); # If upgrading to use_moose=1 replace default custom content with default Moose custom content. # If there is already custom content, which does not have the Moose content, add it. @@ -1355,10 +1355,10 @@ sub _write_classfile { }; if ($custom_content eq $non_moose_custom_content) { - $custom_content = $self->_default_custom_content; + $custom_content = $self->_default_custom_content($is_schema); } - elsif ($custom_content !~ /\Q@{[$self->_default_moose_custom_content]}\E/) { - $custom_content .= $self->_default_custom_content; + elsif ($custom_content !~ /\Q@{[$self->_default_moose_custom_content($is_schema)]}\E/) { + $custom_content .= $self->_default_custom_content($is_schema); } } elsif (defined $self->use_moose && $old_gen) { @@ -1404,15 +1404,21 @@ sub _write_classfile { } sub _default_moose_custom_content { - return qq|\n__PACKAGE__->meta->make_immutable;|; + my ($self, $is_schema) = @_; + + if (not $is_schema) { + return qq|\n__PACKAGE__->meta->make_immutable;|; + } + + return qq|\n__PACKAGE__->meta->make_immutable(inline_constructor => 0);|; } sub _default_custom_content { - my $self = shift; + my ($self, $is_schema) = @_; my $default = qq|\n\n# You can replace this text with custom| . qq| code or comments, and it will be preserved on regeneration|; if ($self->use_moose) { - $default .= $self->_default_moose_custom_content; + $default .= $self->_default_moose_custom_content($is_schema); } $default .= qq|\n1;\n|; return $default; diff --git a/t/26dump_use_moose.t b/t/26dump_use_moose.t index 9740285..d24001d 100644 --- a/t/26dump_use_moose.t +++ b/t/26dump_use_moose.t @@ -29,8 +29,8 @@ $t->dump_test( ], regexes => { schema => [ - qr/\nuse Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;\nextends 'My::SchemaBaseClass';\n\n/, - qr/\n__PACKAGE__->meta->make_immutable;\n1;(?!\n1;\n)\n.*/, + qr/\nuse Moose;\nuse namespace::autoclean;\nextends 'My::SchemaBaseClass';\n\n/, + qr/\n__PACKAGE__->meta->make_immutable\(inline_constructor => 0\);\n1;(?!\n1;\n)\n.*/, ], Foo => [ qr/\nuse Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;\nextends 'My::ResultBaseClass';\n\n/, @@ -86,8 +86,8 @@ $t->dump_test( ], regexes => { schema => [ - qr/\nuse Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;\nextends 'My::SchemaBaseClass';\n\n/, - qr/\n__PACKAGE__->meta->make_immutable;\n1;(?!\n1;\n)\n.*/, + qr/\nuse Moose;\nuse namespace::autoclean;\nextends 'My::SchemaBaseClass';\n\n/, + qr/\n__PACKAGE__->meta->make_immutable\(inline_constructor => 0\);\n1;(?!\n1;\n)\n.*/, ], Foo => [ qr/\nuse Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;\nextends 'My::ResultBaseClass';\n\n/, @@ -146,8 +146,8 @@ for my $supply_use_moose (1, 0) { ], regexes => { schema => [ - qr/\nuse Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;\nextends 'My::SchemaBaseClass';\n\n/, - qr/\n__PACKAGE__->meta->make_immutable;\n1;(?!\n1;\n)\n.*/, + qr/\nuse Moose;\nuse namespace::autoclean;\nextends 'My::SchemaBaseClass';\n\n/, + qr/\n__PACKAGE__->meta->make_immutable\(inline_constructor => 0\);\n1;(?!\n1;\n)\n.*/, ], Foo => [ qr/\nuse Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;\nextends 'My::ResultBaseClass';\n\n/,