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