CatalystX-CRUD-ModelAdapter-DBIC

 view release on metacpan or  search on metacpan

lib/CatalystX/CRUD/ModelAdapter/DBIC.pm  view on Meta::CPAN

    my @fields;
    for my $rel (@rels) {
        my $info = $self->_get_rel_meta( $controller, $c, $table_obj, $rel );
        my ( $rel_class, $prefix );

        #warn "rel info for $moniker $rel: " . dump $info;
        if ( exists $info->{m2m} ) {
            $rel_class = $info->{m2m}->{foreign_class};
            $prefix    = $info->{m2m}->{map_to};
        }
        else {
            $rel_class = $info->{class};
            $prefix    = $rel;
        }
        my @rel_cols = $rel_class->columns;
        push( @fields, map { $prefix . '.' . $_ } @rel_cols );
    }
    for my $col (@cols) {
        push( @fields, 'me.' . $col );
    }

    #carp sprintf( "field_names for %s [%s] : %s",
    #    $moniker, $self->model_name, dump \@fields );

    $self->{_field_names} = \@fields;

    return \@fields;
}

=head2 create( I<context>, I<dbic_object> )

Calls insert() on I<dbic_object>.

=cut

sub create {
    my ( $self, $c, $object ) = @_;
    $object->insert;
}

=head2 read( I<context>, I<dbic_object> )

Calls find() on I<dbic_object>.

=cut

sub read {
    my ( $self, $c, $object ) = @_;

    #$object->find;    # TODO is this right? what about discard_changes()?
    $c->log->error("TODO $object does not implement find() method");
    return $object;
}

=head2 update( I<context>, I<dbic_object> )

Calls update() on I<dbic_object>.

=cut

sub update {
    my ( $self, $c, $object ) = @_;
    $object->update;
}

=head2 delete( I<context>, I<dbic_object> )

Calls delete() on I<dbic_object>.

=cut

sub delete {
    my ( $self, $c, $object ) = @_;
    $object->delete;
}

=head1 AUTHOR

Peter Karman, C<< <karman at cpan.org> >>

=head1 BUGS

Please report any bugs or feature requests to
C<bug-catalystx-crud-modeladapter-dbic at rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-CRUD-ModelAdapter-DBIC>.
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 CatalystX::CRUD::ModelAdapter::DBIC

You can also look for information at:

=over 4

=item * Mailing List

L<https://groups.google.com/forum/#!forum/catalystxcrud>

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/CatalystX-CRUD-ModelAdapter-DBIC>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/CatalystX-CRUD-ModelAdapter-DBIC>

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CatalystX-CRUD-ModelAdapter-DBIC>

=item * Search CPAN

L<http://search.cpan.org/dist/CatalystX-CRUD-ModelAdapter-DBIC>

=back

=head1 ACKNOWLEDGEMENTS



( run in 1.006 second using v1.01-cache-2.11-cpan-39bf76dae61 )