DBIx-Class-Schema-Loader
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/DBIx/Class/Schema/Loader/Base.pm view on Meta::CPAN
be generated.
filter_generated_code => sub {
my ($type, $class, $text) = @_;
...
return $new_code;
}
You can also use this option to set L<perltidy markers|perltidy/Skipping
Selected Sections of Code> in your generated classes. This will leave
the generated code in the default format, but will allow you to tidy
your classes at any point in future, without worrying about changing the
portions of the file which are checksummed, since C<perltidy> will just
ignore all text between the markers.
filter_generated_code => sub {
return "#<<<\n$_[2]\n#>>>";
}
=head1 METHODS
None of these methods are intended for direct invocation by regular
users of L<DBIx::Class::Schema::Loader>. Some are proxied via
L<DBIx::Class::Schema::Loader>.
=cut
# ensure that a piece of object data is a valid arrayref, creating
# an empty one or encapsulating whatever's there.
sub _ensure_arrayref {
my $self = shift;
foreach (@_) {
$self->{$_} ||= [];
$self->{$_} = [ $self->{$_} ]
unless ref $self->{$_} eq 'ARRAY';
}
}
=head2 new
Constructor for L<DBIx::Class::Schema::Loader::Base>, used internally
by L<DBIx::Class::Schema::Loader>.
=cut
sub new {
my ( $class, %args ) = @_;
if (exists $args{column_accessor_map}) {
$args{col_accessor_map} = delete $args{column_accessor_map};
}
my $self = { %args };
# don't lose undef options
for (values %$self) {
$_ = 0 unless defined $_;
}
bless $self => $class;
if (my $config_file = $self->config_file) {
my $config_opts = do $config_file;
croak "Error reading config from $config_file: $@" if $@;
croak "Config file $config_file must be a hashref" unless ref($config_opts) eq 'HASH';
while (my ($k, $v) = each %$config_opts) {
$self->{$k} = $v unless exists $self->{$k};
}
}
if (defined $self->{result_component_map}) {
if (defined $self->result_components_map) {
croak "Specify only one of result_components_map or result_component_map";
}
$self->result_components_map($self->{result_component_map})
}
if (defined $self->{result_role_map}) {
if (defined $self->result_roles_map) {
croak "Specify only one of result_roles_map or result_role_map";
}
$self->result_roles_map($self->{result_role_map})
}
croak "the result_roles and result_roles_map options may only be used in conjunction with use_moose=1"
if ((not defined $self->use_moose) || (not $self->use_moose))
&& ((defined $self->result_roles) || (defined $self->result_roles_map));
$self->_ensure_arrayref(qw/schema_components
additional_classes
additional_base_classes
left_base_classes
components
result_roles
/);
$self->_validate_class_args;
croak "result_components_map must be a hash"
if defined $self->result_components_map
&& ref $self->result_components_map ne 'HASH';
if ($self->result_components_map) {
my %rc_map = %{ $self->result_components_map };
foreach my $moniker (keys %rc_map) {
$rc_map{$moniker} = [ $rc_map{$moniker} ] unless ref $rc_map{$moniker};
}
$self->result_components_map(\%rc_map);
}
else {
$self->result_components_map({});
}
$self->_validate_result_components_map;
croak "result_roles_map must be a hash"
if defined $self->result_roles_map
&& ref $self->result_roles_map ne 'HASH';
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.436 second using v1.00-cache-2.02-grep-82fe00e-cpan-503542c4f10 )