use strict;
use warnings;
+use Carp::Clan qw/^DBIx::Class/;
+
=head1 NAME
DBIx::Class::AccessorGroup - Lets you build groups of accessors
=head1 METHODS
-=over 4
-
=cut
sub mk_group_accessors {
foreach my $field (@fields) {
if( $field eq 'DESTROY' ) {
- require Carp;
- &Carp::carp("Having a data accessor named DESTROY in ".
+ carp("Having a data accessor named DESTROY in ".
"'$class' is unwise.");
}
if(@_) {
my $caller = caller;
- require Carp;
- Carp::croak("'$caller' cannot alter the value of '$field' on ".
+ croak("'$caller' cannot alter the value of '$field' on ".
"objects of class '$class'");
}
else {
unless (@_) {
my $caller = caller;
require Carp;
- Carp::croak("'$caller' cannot access the value of '$field' on ".
+ croak("'$caller' cannot access the value of '$field' on ".
"objects of class '$class'");
}
else {
return $self->{$set} = $val;
}
-1;
+sub get_component_class {
+ my ($self, $get) = @_;
+ if (ref $self) {
+ return $self->{$get};
+ } else {
+ $get = "_$get";
+ return $self->can($get) ? $self->$get : undef;
+ }
+}
-=back
+sub set_component_class {
+ my ($self, $set, $val) = @_;
+ eval "require $val";
+ if (ref $self) {
+ return $self->{$set} = $val;
+ } else {
+ $set = "_$set";
+ return $self->can($set) ? $self->$set($val) : $self->mk_classdata($set => $val);
+ }
+}
+
+1;
=head1 AUTHORS