AccessorGroup is now a Class::Accessor::Grouped subclass
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / AccessorGroup.pm
index 7a2da2c..f553a87 100644 (file)
@@ -3,127 +3,27 @@ package DBIx::Class::AccessorGroup;
 use strict;
 use warnings;
 
-use base qw/Class::Data::Inheritable/;
+use base qw/Class::Accessor::Grouped/;
 
-__PACKAGE__->mk_classdata('_accessor_group_deleted' => { });
+=head1 NAME
 
-sub mk_group_accessors {
-    my($self, $group, @fields) = @_;
+DBIx::Class::AccessorGroup - See Class::Accessor::Grouped
 
-    $self->_mk_group_accessors('make_group_accessor', $group, @fields);
-}
+=head1 SYNOPSIS
 
+=head1 DESCRIPTION
 
-{
-    no strict 'refs';
-    no warnings 'redefine';
+This class now exists in its own right on CPAN as Class::Accessor::Grouped
 
-    sub _mk_group_accessors {
-        my($self, $maker, $group, @fields) = @_;
-        my $class = ref $self || $self;
-
-        # So we don't have to do lots of lookups inside the loop.
-        $maker = $self->can($maker) unless ref $maker;
-
-        foreach my $field (@fields) {
-            if( $field eq 'DESTROY' ) {
-                require Carp;
-                &Carp::carp("Having a data accessor named DESTROY  in ".
-                             "'$class' is unwise.");
-            }
-
-            my $accessor = $self->$maker($group, $field);
-            my $alias = "_${field}_accessor";
-
-            #warn "$class $group $field $alias";
-
-            *{$class."\:\:$field"}  = $accessor;
-              #unless defined &{$class."\:\:$field"}
-
-            *{$class."\:\:$alias"}  = $accessor;
-              #unless defined &{$class."\:\:$alias"}
-        }
-    }
-}
-
-sub mk_group_ro_accessors {
-    my($self, $group, @fields) = @_;
-
-    $self->_mk_group_accessors('make_group_ro_accessor', $group, @fields);
-}
-
-sub mk_group_wo_accessors {
-    my($self, $group, @fields) = @_;
-
-    $self->_mk_group_accessors('make_group_wo_accessor', $group, @fields);
-}
-
-sub make_group_accessor {
-    my ($class, $group, $field) = @_;
-
-    my $set = "set_$group";
-    my $get = "get_$group";
-
-    # Build a closure around $field.
-    return sub {
-        my $self = shift;
-
-        if(@_) {
-            return $self->$set($field, @_);
-        }
-        else {
-            return $self->$get($field);
-        }
-    };
-}
-
-sub make_group_ro_accessor {
-    my($class, $group, $field) = @_;
-
-    my $get = "get_$group";
-
-    return sub {
-        my $self = shift;
-
-        if(@_) {
-            my $caller = caller;
-            require Carp;
-            Carp::croak("'$caller' cannot alter the value of '$field' on ".
-                        "objects of class '$class'");
-        }
-        else {
-            return $self->$get($field);
-        }
-    };
-}
+1;
 
-sub make_group_wo_accessor {
-    my($class, $group, $field) = @_;
+=head1 AUTHORS
 
-    my $set = "set_$group";
+Matt S. Trout <mst@shadowcatsystems.co.uk>
 
-    return sub {
-        my $self = shift;
+=head1 LICENSE
 
-        unless (@_) {
-            my $caller = caller;
-            require Carp;
-            Carp::croak("'$caller' cannot access the value of '$field' on ".
-                        "objects of class '$class'");
-        }
-        else {
-            return $self->$set($field, @_);
-        }
-    };
-}
+You may distribute this code under the same terms as Perl itself.
 
-sub delete_accessor {
-  my ($class, $accessor) = @_;
-  $class = ref $class if ref $class;
-  my $sym = "${class}::${accessor}";
-  undef &$sym;
-  delete $DB::sub{$sym};
-  #$class->_accessor_group_deleted->{"${class}::${accessor}"} = 1;
-}
+=cut
 
-1;