Add an explicit Sub::Quote dep in ::_Util
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / ResultSetManager.pm
CommitLineData
db57afbb 1package DBIx::Class::ResultSetManager;
ed28f830 2use strict;
bf5ecff9 3use warnings;
ed28f830 4use base 'DBIx::Class';
ed28f830 5
b090048f 6use DBIx::Class::_Util qw( set_subname describe_class_methods );
514b84f6 7use namespace::clean;
8
748ab0dc 9warn "DBIx::Class::ResultSetManager never left experimental status and
10has now been DEPRECATED. This module will be deleted in 09000 so please
11migrate any and all code using it to explicit resultset classes using either
12__PACKAGE__->resultset_class(...) calls or by switching from using
13DBIx::Class::Schema->load_classes() to load_namespaces() and creating
14appropriate My::Schema::ResultSet::* classes for it to pick up.";
bc0c9800 15
748ab0dc 16=head1 NAME
bc0c9800 17
748ab0dc 18DBIx::Class::ResultSetManager - scheduled for deletion in 09000
bc0c9800 19
20=head1 DESCRIPTION
21
748ab0dc 22DBIx::Class::ResultSetManager never left experimental status and
23has now been DEPRECATED. This module will be deleted in 09000 so please
24migrate any and all code using it to explicit resultset classes using either
25__PACKAGE__->resultset_class(...) calls or by switching from using
26DBIx::Class::Schema->load_classes() to load_namespaces() and creating
27appropriate My::Schema::ResultSet::* classes for it to pick up.";
bc0c9800 28
29=cut
30
e5053694 31__PACKAGE__->mk_group_accessors(inherited => qw(
32 base_resultset_class table_resultset_class_suffix
33));
570783b1 34__PACKAGE__->base_resultset_class('DBIx::Class::ResultSet');
f0750722 35__PACKAGE__->table_resultset_class_suffix('::_resultset');
ed28f830 36
37sub table {
38 my ($self,@rest) = @_;
e8861f71 39 my $ret = $self->next::method(@rest);
40 if (@rest) {
41 $self->_register_attributes;
75d07914 42 $self->_register_resultset_class;
e8861f71 43 }
44 return $ret;
ed28f830 45}
46
47sub load_resultset_components {
48 my ($self,@comp) = @_;
49 my $resultset_class = $self->_setup_resultset_class;
50 $resultset_class->load_components(@comp);
51}
52
ed28f830 53sub _register_attributes {
54 my $self = shift;
55 my $cache = $self->_attr_cache;
da95b45f 56 return if keys %$cache == 0;
9b83fccd 57
b090048f 58 for my $meth(
817ac9e9 59 map
b090048f 60 { $_->{name} }
61 grep
62 { $_->{attributes}{ResultSet} }
63 map
64 { $_->[0] }
65 values %{ describe_class_methods( ref $self || $self )->{methods} }
66 ) {
817ac9e9 67 # This codepath is extremely old, miht as well keep it running
68 # as-is with no room for surprises
b090048f 69 no strict 'refs';
70 my $resultset_class = $self->_setup_resultset_class;
71 my $name = join '::',$resultset_class, $meth;
72 *$name = set_subname $name, $self->can($meth);
73 delete ${"${self}::"}{$meth};
ed28f830 74 }
ed28f830 75}
76
77sub _setup_resultset_class {
78 my $self = shift;
f0750722 79 my $resultset_class = $self . $self->table_resultset_class_suffix;
ed28f830 80 no strict 'refs';
81 unless (@{"$resultset_class\::ISA"}) {
570783b1 82 @{"$resultset_class\::ISA"} = ($self->base_resultset_class);
ed28f830 83 }
84 return $resultset_class;
85}
86
570783b1 87sub _register_resultset_class {
88 my $self = shift;
f0750722 89 my $resultset_class = $self . $self->table_resultset_class_suffix;
570783b1 90 no strict 'refs';
91 if (@{"$resultset_class\::ISA"}) {
24d67825 92 $self->result_source_instance->resultset_class($resultset_class);
570783b1 93 } else {
24d67825 94 $self->result_source_instance->resultset_class
75d07914 95 ($self->base_resultset_class);
570783b1 96 }
97}
98
a2bd3796 99=head1 FURTHER QUESTIONS?
100
101Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
102
103=head1 COPYRIGHT AND LICENSE
104
105This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
106by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
107redistribute it and/or modify it under the same terms as the
108L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
109
110=cut
111
19345968 1121;