Rose::HTMLx::Form::Related::DBIC - DBIC with RHTMLO


Rose-HTMLx-Form-Related documentation Contained in the Rose-HTMLx-Form-Related distribution.

Index


Code Index:

NAME

Top

Rose::HTMLx::Form::Related::DBIC - DBIC with RHTMLO

SYNOPSIS

Top

 package MyDBIC::Class::Form;
 use strict;
 use base qw( Rose::HTMLx::Form::Related::RDBO );

 sub init_object_class { 'MyDBIC::Class' }

 1;

DESCRIPTION

Top

Use Rose::HTML::Objects forms with DBIx::Class.

NOTE: This class requires that your DBIC schema load the DBIx::Class::RDBOHelpers component, available from CPAN. See examples in the t/ test directory with this distribution.

METHODS

Top

init_metadata_class

Returns 'Rose::HTMLx::Form::Related::RDBO::Metadata'.

get_objects( object_class => class )

Overrides base method to use schema_class() to fetch objects of class.

If you are using the deploy() feature of DBIC you may encounter a race condition where the schema has not yet fully populated. In that case, you may want to set the DBIC_DEPLOY_IN_PROGRESS environment variable prior to instantiating this Form. If that variable is set to a true value, get_objects() and get_objects_count() will both return undef, which should abort the interrelate_fields() method (which is what you want).

get_objects_count( object_class => class )

Overrides base method to use schema_class() to fetch object count for class.

See the DBIC_DEPLOY_IN_PROGRESS environment variable above.

AUTHOR

Top

Peter Karman, <karman at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-rose-htmlx-form-related at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Rose-HTMLx-Form-Related. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Rose::HTMLx::Form::Related

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Rose-HTMLx-Form-Related

* CPAN Ratings

http://cpanratings.perl.org/d/Rose-HTMLx-Form-Related

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Rose-HTMLx-Form-Related

* Search CPAN

http://search.cpan.org/dist/Rose-HTMLx-Form-Related

ACKNOWLEDGEMENTS

Top

The Minnesota Supercomputing Institute http://www.msi.umn.edu/ sponsored the development of this software.

COPYRIGHT & LICENSE

Top


Rose-HTMLx-Form-Related documentation Contained in the Rose-HTMLx-Form-Related distribution.
package Rose::HTMLx::Form::Related::DBIC;
use strict;
use warnings;
use base qw( Rose::HTMLx::Form::Related );
use Rose::HTMLx::Form::Related::DBIC::Metadata;
use Carp;
use Data::Dump qw( dump );

our $VERSION = '0.22';

sub init_metadata_class {
    return 'Rose::HTMLx::Form::Related::DBIC::Metadata';
}

sub _get_moniker {
    my ( $self, $schema, $class ) = @_;
    for my $moniker ( $schema->sources ) {
        if ( $schema->class($moniker)->isa($class) ) {
            return $moniker;
        }
    }
    croak "could not find moniker for $class in $schema";
}

sub get_objects {
    return undef if $ENV{DBIC_DEPLOY_IN_PROGRESS};
    my $self    = shift;
    my $class   = pop;
    my $schema  = $self->metadata->schema_class;
    my $moniker = $self->_get_moniker( $schema, $class );
    return [
        $schema->connect( $schema->init_connect_info )->resultset($moniker)
            ->all() ];
}

sub get_objects_count {
    return undef if $ENV{DBIC_DEPLOY_IN_PROGRESS};
    my $self    = shift;
    my $class   = pop;
    my $schema  = $self->metadata->schema_class;
    my $moniker = $self->_get_moniker( $schema, $class );
    return $schema->connect( $schema->init_connect_info )->resultset($moniker)
        ->count();
}

1;

__END__