Catalyst-Helper-Controller-DBIC-API-REST
view release on metacpan or search on metacpan
lib/Catalyst/Helper/Controller/DBIC/API/REST.pm view on Meta::CPAN
The idea is to make configuration as painless and as automatic as possible, so most
of the work has been done for you.
There are 8 __PACKAGE__->config(...) options for L<Catalyst::Controller::DBIC::API/CONFIGURATION>.
Here are the defaults.
=head2 create_requires
All non-nullable columns that are (1) not autoincrementing,
(2) don't have a default value, are neither (3) nextvals,
(4) sequences, nor (5) timestamps.
=head2 create_allows
All nullable columns that are (1) not autoincrementing,
(2) don't have a default value, are neither (3) nextvals,
(4) sequences, nor (5) timestamps.
=head2 update_allows
The union of create_requires and create_allows.
=head2 list_returns
Every column in the class.
=head2 list_prefetch
Nothing is prefetched by default.
=head2 list_prefetch_allows
(1) An arrayref consisting of the name of each of the class's
has_many relationships, accompanied by (2) a hashref keyed on
the name of that relationship, whose values are the names of
its has_many's, e.g., in the "Producer" controller above, a
Producer has many cd_to_producers, many tags, and many tracks.
None of those classes have any has_many's:
list_prefetch_allows => [
[qw/cd_to_producer/], { 'cd_to_producer' => [qw//] },
[qw/tags/], { 'tags' => [qw//] },
[qw/tracks/], { 'tracks' => [qw//] },
],
=head2 list_ordered_by
The primary key.
=head2 list_search_exposes
(1) An arrayref consisting of the name of each column in the class,
and (2) a hashref keyed on the name of each of the class's has many
relationships, the values of which are all the columns in the
corresponding class, e.g.,
list_search_exposes => [
qw/cdid artist title year/,
{ 'cd_to_producer' => [qw/cd producer/] },
{ 'tags' => [qw/tagid cd tag/] },
{ 'tracks' => [qw/trackid cd position title last_updated_on/] },
], # columns that can be searched on via list
=head1 CONTROLLERBASE
Following the advice in L<Catalyst::Controller::DBIC::API/EXTENDING>, this
module creates an intermediate class between your controllers and
L<Catalyst::Controller::DBIC::API::REST>. It contains one method, create,
which serializes object information and stores it in the stash, which is
not the default behavior.
=head1 METHODS
=head2 mk_compclass
This is the meat of the helper. It writes the directory structure if it is
not in place, API.pm, REST.pm, the controllerbase, and the result class
controllers. It replaces $helper->{} values as it goes through, rendering
the files for each.
=over
=back
=head1 AUTHOR
Amiri Barksdale E<lt>amiri@roosterpirates.comE<gt>
=head1 CONTRIBUTORS
Franck Cuny (lumberjaph) <franck@lumberjaph.net>
Pablo RodrÃguez González <pablo.rodriguez.gonzalez@gmail.com>
Chris Weyl (RsrchBoy) <cweyl@alumni.drew.edu>
=head1 SEE ALSO
L<Catalyst::Controller::DBIC::API>
L<Catalyst::Controller::DBIC::API::REST>
L<Catalyst::Controller::DBIC::API::RPC>
=head1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
sub mk_compclass {
my ( $self, $helper, $schema_class, $model, @extra_options ) = @_;
my %extra_options = map {split /=/} @extra_options;
$schema_class ||= $helper->{app} . '::Schema';
$model ||= $helper->{app} . '::Model::DB';
( my $model_base = $model ) =~ s/^.*::Model:://;
$helper->{script} = File::Spec->catdir( $helper->{dir}, 'script' ) if $helper->{dir};
$helper->{appprefix} = Catalyst::Utils::appprefix( $helper->{name} );
( run in 0.599 second using v1.01-cache-2.11-cpan-5735350b133 )