1 package DBIx::Class::AccessorGroup;
6 use base qw( DBIx::Class::MethodAttributes Class::Accessor::Grouped );
8 use Scalar::Util 'blessed';
9 use DBIx::Class::_Util 'fail_on_internal_call';
12 sub mk_classdata :DBIC_method_is_indirect_sugar {
13 DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
14 shift->mk_classaccessor(@_);
17 sub mk_classaccessor :DBIC_method_is_indirect_sugar {
19 $self->mk_group_accessors('inherited', $_[0]);
21 ? $self->set_inherited(@_)
22 : ( DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call )
26 sub mk_group_accessors {
30 $class->next::method($type, @_);
33 if( $type =~ /^ ( inflated_ | filtered_ )? column $/x ) {
40 { [ $_, "_${_}_accessor" ] }
42 { ref $_ ? $_->[0] : $_ }
48 my $acc_name = $acc_pair->[$i];
53 $class->can($acc_name)
55 Carp::confess("Accessor '$acc_name' we just created on $class can't be found...?")
57 'DBIC_method_is_generated_from_resultsource_metadata',
59 ? "DBIC_method_is_${type}_extra_accessor"
60 : "DBIC_method_is_${type}_accessor"
66 elsif( $type eq 'inherited_ro_instance' ) {
67 DBIx::Class::Exception->throw(
68 "The 'inherted_ro_instance' CAG group has been retired - use 'inherited' instead"
73 sub get_component_class {
74 my $class = $_[0]->get_inherited($_[1]);
80 # inherited CAG can't be set to undef effectively, so people may use ''
83 # It's already an object, just go for it.
84 ! defined blessed $class
86 ! ${"${class}::__LOADED__BY__DBIC__CAG__COMPONENT_CLASS__"}
88 $_[0]->ensure_class_loaded($class);
90 ${"${class}::__LOADED__BY__DBIC__CAG__COMPONENT_CLASS__"}
91 = do { \(my $anon = 'loaded') };
97 sub set_component_class {
98 $_[0]->set_inherited($_[1], $_[2]);
100 # trigger a load for the case of $foo->component_accessor("bar")->new
101 $_[0]->get_component_class($_[1])
102 if defined wantarray;
109 DBIx::Class::AccessorGroup - See Class::Accessor::Grouped
115 This class now exists in its own right on CPAN as Class::Accessor::Grouped
117 =head1 FURTHER QUESTIONS?
119 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
121 =head1 COPYRIGHT AND LICENSE
123 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
124 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
125 redistribute it and/or modify it under the same terms as the
126 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.