DBIx-Class-Objects
view release on metacpan or search on metacpan
lib/DBIx/Class/Objects/Base.pm view on Meta::CPAN
package DBIx::Class::Objects::Base;
$DBIx::Class::Objects::Base::VERSION = '0.05';
use Moose;
use DBIx::Class::Objects::Util 'class_name_to_private_accessor';
sub BUILD {
my $self = shift;
my @parents = grep { $_ ne __PACKAGE__ } $self->meta->superclasses;
my $source = $self->result_source;
my @relationships = $source->relationships;
foreach my $relationship (@relationships) {
my $info = $source->relationship_info($relationship);
next if 'multi' eq $info->{attrs}{accessor};
my $parent = $info->{_result_class_to_object_class};
next unless $self->isa($parent);
my $accessor = class_name_to_private_accessor($parent);
$self->$accessor( $self->$relationship->result_source );
}
}
sub update {
my $self = shift;
foreach my $attribute ( $self->meta->get_all_attributes ) {
next
unless $attribute->does(
'DBIx::Class::Objects::Attribute::Trait::DBIC');
my $name = $attribute->name;
$self->$name->update;
}
}
sub delete {
my $self = shift;
$self->result_source->delete;
}
1;
__END__
=head1 NAME
DBIx::Class::Objects::Base - Base class for DBIx::Class::Objects objects
=head1 VERSION
version 0.05
Adds an C<update> method to the objects to allow them to also update any
inherited objects.
=head1 AUTHOR
Curtis "Ovid" Poe, C<< <ovid at cpan.org> >>
Dan Burke C<< dburke at addictmud.org >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-object-bridge at
rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-Objects>. I will be
notified, and then you'll automatically be notified of progress on your bug as
I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc DBIx::Class::Objects
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker (report bugs here)
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-Objects>
=item * AnnoCPAN: Annotated CPAN documentation
( run in 2.120 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )