-
-
14 Jul 2017 16:29:41 UTC
- Distribution: DBIx-Class-Candy
- Module version: 0.005003
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (5949 / 0 / 0)
- Kwalitee
Bus factor: 1- 83.09% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (22.49KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors-
Arthur Axel "fREW" Schmidt
- NAME
- SYNOPSIS
- DESCRIPTION
- IMPORT OPTIONS
- SETTING DEFAULT IMPORT OPTIONS
- AUTHOR
- COPYRIGHT AND LICENSE
NAME
DBIx::Class::Candy::ResultSet - Sugar for your resultsets
SYNOPSIS
package MyApp::Schema::ResultSet::Artist; use DBIx::Class::Candy::ResultSet -components => ['Helper::ResultSet::Me']; use experimental 'signatures'; sub by_name ($self, $name) { $self->search({ $self->me . 'name' => $name }) } 1;
DESCRIPTION
DBIx::Class::Candy::ResultSet
is an initial sugar layer in the spirit of DBIx::Class::Candy. Unlike the original it does not define a DSL, though I do have plans for that in the future. For now all it does is set some imports:turns on strict and warnings
sets your parent class
sets your mro to
c3
IMPORT OPTIONS
See "SETTING DEFAULT IMPORT OPTIONS" for information on setting these schema wide.
-base
use DBIx::Class::Candy::ResultSet -base => 'MyApp::Schema::ResultSet';
The first thing you can do to customize your usage of
DBIx::Class::Candy::ResultSet
is change the parent class. Do that by using the-base
import option.-components
use DBIx::Class::Candy::ResultSet -components => ['Helper::ResultSet::Me'];
DBIx::Class::Candy::ResultSet
allows you to set which components you are using at import time.-perl5
use DBIx::Class::Candy::ResultSet -perl5 => v20;
I love the new features in Perl 5.20, so I felt that it would be nice to remove the boiler plate of doing
use feature ':5.20'
and add it to my sugar importer. Feel free not to use this.SETTING DEFAULT IMPORT OPTIONS
Eventually you will get tired of writing the following in every single one of your resultsets:
use DBIx::Class::Candy::ResultSet -base => 'MyApp::Schema::ResultSet', -perl5 => v20, -experimental => ['signatures'];
You can set all of these for your whole schema if you define your own
Candy::ResultSet
subclass as follows:package MyApp::Schema::Candy::ResultSet; use base 'DBIx::Class::Candy::ResultSet'; sub base { $_[1] || 'MyApp::Schema::ResultSEt' } sub perl_version { 20 } sub experimental { ['signatures'] }
Note the
$_[1] ||
inbase
. All of these methods are passed the values passed in from the arguments to the subclass, so you can either throw them away, honor them, die on usage, or whatever. To be clear, if you define your subclass, and someone uses it as follows:use MyApp::Schema::Candy::ResultSet -base => 'MyApp::Schema::ResultSet', -perl5 => v18, -experimental => ['postderef'];
Your
base
method will getMyApp::Schema::ResultSet
, yourexperimental
will get['postderef']
, and yourperl_version
will get18
.AUTHOR
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install DBIx::Class::Candy, copy and paste the appropriate command in to your terminal.
cpanm DBIx::Class::Candy
perl -MCPAN -e shell install DBIx::Class::Candy
For more information on module installation, please visit the detailed CPAN module installation guide.