CatalystX::Usul::File::ResultSource - A source of result sets for a given schema


CatalystX-Usul documentation Contained in the CatalystX-Usul distribution.

Index


Code Index:

Name

Top

CatalystX::Usul::File::ResultSource - A source of result sets for a given schema

Version

Top

0.3.$Revision: 576 $

Synopsis

Top

   use CatalystX::Usul::File;

   $attrs = { schema_attributes => { ... } };

   $result_source = CatalystX::Usul::File->new( $app, $attrs );

   $result_source->resultset( $file, $lang );

Description

Top

Provides new result sets for a given schema. Ideas robbed from DBIx::Class

Subroutines/Methods

Top

new

Constructor's arguments are the application object and a hash ref of schema attributes. Creates a new instance of the schema class which defaults to CatalystX::Usul::File::Schema

resultset

Sets the schema's file and lang attributes from the optional parameters. Creates and returns a new CatalystX::Usul::File::Resultset object

storage

Returns the storage handle for the current schema

Diagnostics

Top

None

Configuration and Environment

Top

None

Dependencies

Top

CatalystX::Usul
CatalystX::Usul::File::Schema

Incompatibilities

Top

There are no known incompatibilities in this module

Bugs and Limitations

Top

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Top

Peter Flanigan, <Support at RoxSoft.co.uk>

License and Copyright

Top


CatalystX-Usul documentation Contained in the CatalystX-Usul distribution.

# @(#)$Id: ResultSource.pm 576 2009-06-09 23:23:46Z pjf $

package CatalystX::Usul::File::ResultSource;

use strict;
use warnings;
use version; our $VERSION = qv( sprintf '0.3.%d', q$Rev: 576 $ =~ /\d+/gmx );
use parent qw(CatalystX::Usul);

use CatalystX::Usul::File::ResultSet;
use CatalystX::Usul::File::Schema;
use Class::C3;

__PACKAGE__->config
   ( resultset_attributes => {},
     resultset_class      => q(CatalystX::Usul::File::ResultSet),
     schema_class         => q(CatalystX::Usul::File::Schema) );

__PACKAGE__->mk_accessors( qw(resultset_attributes resultset_class
                              schema schema_class) );

sub new {
   my ($self, $app, $attrs) = @_;

   my $new = $self->next::method( $app, $attrs );

   $attrs  = { %{ $attrs->{schema_attributes} || {} }, source => $new };
   $new->schema( $new->schema_class->new( $app, $attrs ) );

   return $new;
}

sub resultset {
   my ($self, $path, $lang) = @_;

   $self->storage->path( $path ) if ($path);
   $self->storage->lang( $lang ) if ($lang);

   return $self->resultset_class->new( $self, $self->resultset_attributes );
}

sub storage {
   return shift->schema->storage;
}

1;

__END__

# Local Variables:
# mode: perl
# tab-width: 3
# End: