package DBIx::Class::AccessorGroup;
+use strict;
+use warnings;
+
+use NEXT;
+
+=head1 NAME
+
+DBIx::Class::AccessorGroup - Lets you build groups of accessors
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+This class lets you build groups of accessors that will call different
+getters and setters.
+
+=head1 METHODS
+
+=over 4
+
+=cut
+
sub mk_group_accessors {
my($self, $group, @fields) = @_;
{
no strict 'refs';
+ no warnings 'redefine';
sub _mk_group_accessors {
my($self, $maker, $group, @fields) = @_;
"'$class' is unwise.");
}
+ my $name = $field;
+
+ ($name, $field) = @$field if ref $field;
+
my $accessor = $self->$maker($group, $field);
- my $alias = "_${field}_accessor";
+ my $alias = "_${name}_accessor";
+
+ #warn "$class $group $field $alias";
- *{$class."\:\:$field"} = $accessor
- unless defined &{$class."\:\:$field"};
+ *{$class."\:\:$name"} = $accessor;
+ #unless defined &{$class."\:\:$field"}
- *{$class."\:\:$alias"} = $accessor
- unless defined &{$class."\:\:$alias"};
+ *{$class."\:\:$alias"} = $accessor;
+ #unless defined &{$class."\:\:$alias"}
}
}
}
my $self = shift;
if(@_) {
- return $self->set($field, @_);
+ return $self->$set($field, @_);
}
else {
- return $self->get($field);
+ return $self->$get($field);
}
};
}
"objects of class '$class'");
}
else {
- return $self->get($field);
+ return $self->$get($field);
}
};
}
"objects of class '$class'");
}
else {
- return $self->set($field, @_);
+ return $self->$set($field, @_);
}
};
}
1;
+
+=back
+
+=head1 AUTHORS
+
+Matt S. Trout <mst@shadowcatsystems.co.uk>
+
+=head1 LICENSE
+
+You may distribute this code under the same terms as Perl itself.
+
+=cut
+