Streamline ::ResultSource::* inheritance, similar to d009cb7d
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / AccessorGroup.pm
CommitLineData
fe5d862b 1package DBIx::Class::AccessorGroup;
2
12bbb339 3use strict;
4use warnings;
5
73281318 6use base qw/Class::Accessor::Grouped/;
91fe73bc 7use Scalar::Util qw/weaken blessed/;
e5053694 8use DBIx::Class::_Util 'fail_on_internal_call';
0d374214 9use namespace::clean;
701da8c4 10
d009cb7d 11sub mk_classdata {
e5053694 12 DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
d009cb7d 13 shift->mk_classaccessor(@_);
14}
15
16sub mk_classaccessor {
17 my $self = shift;
18 $self->mk_group_accessors('inherited', $_[0]);
e5053694 19 (@_ > 1)
20 ? $self->set_inherited(@_)
21 : ( DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call )
22 ;
d009cb7d 23}
24
0d374214 25my $successfully_loaded_components;
db29433c 26
27sub get_component_class {
28 my $class = $_[0]->get_inherited($_[1]);
0d374214 29
91fe73bc 30 # It's already an object, just go for it.
31 return $class if blessed $class;
32
0d374214 33 if (defined $class and ! $successfully_loaded_components->{$class} ) {
db29433c 34 $_[0]->ensure_class_loaded($class);
0d374214 35
d009cb7d 36 mro::set_mro( $class, 'c3' );
37
0d374214 38 no strict 'refs';
39 $successfully_loaded_components->{$class}
40 = ${"${class}::__LOADED__BY__DBIC__CAG__COMPONENT_CLASS__"}
41 = do { \(my $anon = 'loaded') };
42 weaken($successfully_loaded_components->{$class});
db29433c 43 }
0d374214 44
db29433c 45 $class;
46};
47
48sub set_component_class {
49 shift->set_inherited(@_);
50}
51
fe0e9f67 521;
53
75d07914 54=head1 NAME
34d52be2 55
73281318 56DBIx::Class::AccessorGroup - See Class::Accessor::Grouped
34d52be2 57
58=head1 SYNOPSIS
59
60=head1 DESCRIPTION
61
73281318 62This class now exists in its own right on CPAN as Class::Accessor::Grouped
fc969005 63
a2bd3796 64=head1 FURTHER QUESTIONS?
34d52be2 65
a2bd3796 66Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
34d52be2 67
a2bd3796 68=head1 COPYRIGHT AND LICENSE
34d52be2 69
a2bd3796 70This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
71by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
72redistribute it and/or modify it under the same terms as the
73L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
34d52be2 74
75=cut