DBIx::Class::Helper::ResultSet::EnumMethods - Automatically create search methods for enum columns.
Version 0.02
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__));
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', } }); };
Mathieu Arnold, <mat at cpan.org>
<mat at cpan.org>
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.
bug-dbix-class-helper-resultset-enummethods at rt.cpan.org
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
People on #dbix-class for the original idea.
This software is Copyright (c) 2019 by Mathieu Arnold.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install DBIx::Class::Helper::ResultSet::EnumMethods, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class::Helper::ResultSet::EnumMethods
CPAN shell
perl -MCPAN -e shell install DBIx::Class::Helper::ResultSet::EnumMethods
For more information on module installation, please visit the detailed CPAN module installation guide.