File Coverage

blib/lib/DBIx/Class/ResultSetManager.pm
Criterion Covered Total %
statement 55 59 93.2
branch 8 14 57.1
condition n/a
subroutine 12 13 92.3
pod 0 2 0.0
total 75 88 85.2


line stmt bran cond sub pod time code
1             package DBIx::Class::ResultSetManager;
2 3     3   1740 use strict;
  3         9  
  3         95  
3 3     3   17 use warnings;
  3         5  
  3         74  
4 3     3   18 use base 'DBIx::Class';
  3         6  
  3         290  
5 3     3   20 use Sub::Name ();
  3         6  
  3         52  
6 3     3   1401 use Class::Inspector;
  3         7841  
  3         592  
7              
8             warn "DBIx::Class::ResultSetManager never left experimental status and
9             has now been DEPRECATED. This module will be deleted in 09000 so please
10             migrate any and all code using it to explicit resultset classes using either
11             __PACKAGE__->resultset_class(...) calls or by switching from using
12             DBIx::Class::Schema->load_classes() to load_namespaces() and creating
13             appropriate My::Schema::ResultSet::* classes for it to pick up.";
14              
15             =head1 NAME
16              
17             DBIx::Class::ResultSetManager - scheduled for deletion in 09000
18              
19             =head1 DESCRIPTION
20              
21             DBIx::Class::ResultSetManager never left experimental status and
22             has now been DEPRECATED. This module will be deleted in 09000 so please
23             migrate any and all code using it to explicit resultset classes using either
24             __PACKAGE__->resultset_class(...) calls or by switching from using
25             DBIx::Class::Schema->load_classes() to load_namespaces() and creating
26             appropriate My::Schema::ResultSet::* classes for it to pick up.";
27              
28             =cut
29              
30             __PACKAGE__->mk_classdata($_)
31             for qw/ base_resultset_class table_resultset_class_suffix /;
32             __PACKAGE__->base_resultset_class('DBIx::Class::ResultSet');
33             __PACKAGE__->table_resultset_class_suffix('::_resultset');
34              
35             sub table {
36 1     1 0 166 my ($self,@rest) = @_;
37 1         6 my $ret = $self->next::method(@rest);
38 1 50       22 if (@rest) {
39 1         7 $self->_register_attributes;
40 1         8 $self->_register_resultset_class;
41             }
42 1         16 return $ret;
43             }
44              
45             sub load_resultset_components {
46 0     0 0 0 my ($self,@comp) = @_;
47 0         0 my $resultset_class = $self->_setup_resultset_class;
48 0         0 $resultset_class->load_components(@comp);
49             }
50              
51             sub _register_attributes {
52 1     1   2 my $self = shift;
53 1         10 my $cache = $self->_attr_cache;
54 1 50       26 return if keys %$cache == 0;
55              
56 1 50       2 foreach my $meth (@{Class::Inspector->methods($self) || []}) {
  1         4  
57 149         3732 my $attrs = $cache->{$self->can($meth)};
58 149 100       330 next unless $attrs;
59 1 50       18 if ($attrs->[0] eq 'ResultSet') {
60 3     3   23 no strict 'refs';
  3         4  
  3         396  
61 1         4 my $resultset_class = $self->_setup_resultset_class;
62 1         4 my $name = join '::',$resultset_class, $meth;
63 1         13 *$name = Sub::Name::subname $name, $self->can($meth);
64 1         5 delete ${"${self}::"}{$meth};
  1         6  
65             }
66             }
67             }
68              
69             sub _setup_resultset_class {
70 1     1   3 my $self = shift;
71 1         30 my $resultset_class = $self . $self->table_resultset_class_suffix;
72 3     3   21 no strict 'refs';
  3         7  
  3         325  
73 1 50       42 unless (@{"$resultset_class\::ISA"}) {
  1         10  
74 1         35 @{"$resultset_class\::ISA"} = ($self->base_resultset_class);
  1         58  
75             }
76 1         4 return $resultset_class;
77             }
78              
79             sub _register_resultset_class {
80 1     1   2 my $self = shift;
81 1         28 my $resultset_class = $self . $self->table_resultset_class_suffix;
82 3     3   26 no strict 'refs';
  3         6  
  3         306  
83 1 50       43 if (@{"$resultset_class\::ISA"}) {
  1         6  
84 1         35 $self->result_source_instance->resultset_class($resultset_class);
85             } else {
86 0           $self->result_source_instance->resultset_class
87             ($self->base_resultset_class);
88             }
89             }
90              
91             =head1 FURTHER QUESTIONS?
92              
93             Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
94              
95             =head1 COPYRIGHT AND LICENSE
96              
97             This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
98             by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
99             redistribute it and/or modify it under the same terms as the
100             L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
101              
102             =cut
103              
104             1;