File Coverage

blib/lib/DBIx/Class/ResultSetManager.pm
Criterion Covered Total %
statement 54 57 94.7
branch 4 8 50.0
condition 1 3 33.3
subroutine 12 13 92.3
pod 0 2 0.0
total 71 83 85.5


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