NAME
DBIx::Class::Helper::ResultSet::EnumMethods - Automatically create search methods for enum columns.
VERSION
Version 0.02
SYNOPSIS
This module automatically creates search method helpers for enum columns.
In your ResultSet class, add:
use Role::Tiny::With qw(with);
use DBIx::Class::Helper::ResultSet::EnumMethods;
with(EnumMethods(__PACKAGE__));
METHODS
Say your table has an enum column "payment_type", and the possible values for the enum are "cash", "check", and "card", using this role will act as if you added these methods:
sub payment_type_cash {
return shift->search( {
$self->me('payment_type') => 'cash'
});
};
sub payment_type_not_cash {
return shift->search( {
$self->me('payment_type') => {
q{!=} => 'cash',
}
});
};
sub payment_type_check {
return shift->search( {
$self->me('payment_type') => 'check'
});
};
sub payment_type_not_check {
return shift->search( {
$self->me('payment_type') => {
q{!=} => 'check',
}
});
};
sub payment_type_card {
return shift->search( {
$self->me('payment_type') => 'card'
});
};
sub payment_type_not_card {
return shift->search( {
$self->me('payment_type') => {
q{!=} => 'card',
}
});
};
AUTHOR
Mathieu Arnold, <mat at cpan.org>
BUGS
Please report any bugs or feature requests to bug-dbix-class-helper-resultset-enummethods at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-Helper-ResultSet-EnumMethods. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc DBIx::Class::Helper::ResultSet::EnumMethods
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-Helper-ResultSet-EnumMethods
CPAN Ratings
https://cpanratings.perl.org/d/DBIx-Class-Helper-ResultSet-EnumMethods
Search CPAN
https://metacpan.org/release/DBIx-Class-Helper-ResultSet-EnumMethods
ACKNOWLEDGEMENTS
People on #dbix-class for the original idea.
LICENSE AND COPYRIGHT
This software is Copyright (c) 2019 by Mathieu Arnold.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)