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