DBIx::...sultSet(3pm)

πŸ“¦
version 0.005004 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– DBIx::...sultSet(3pm) β€” User Contributed Perl Documentation πŸ’–

okay bestie, so this is DBIx::Class::Candy::ResultSet and it's literally the cutest little sugar layer, no cap. come sit with me, it's a short one. ✨


🌸 NAME 🌸

DBIx::Class::Candy::ResultSet β€” Sugar for your resultsets πŸ“


✨ SYNOPSIS ✨

like, here's the whole vibe:

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;

that's it. that's the whole thing. iconic. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so DBIx::Class::Candy::ResultSet is an initial sugar layer, living in the spirit of DBIx::Class::Candy. so sweet, so sugary. 🧁

but β€” and this is important β€” unlike the original it does not define a DSL. nope! not yet. the author lowkey has plans for that in the future though, so keep an eye out πŸ‘€.

for now, all it does is set some imports. and when i say "all it does", i mean it's still doing the most for you:

  • turns on strict and warnings πŸ”₯
  • sets your parent class πŸ‘‘
  • sets your mro to c3 πŸ’€

that's it bestie. main character energy from three whole lines of setup.


πŸŽ€ IMPORT OPTIONS πŸŽ€

See "SETTING DEFAULT IMPORT OPTIONS" for information on setting these schema wide. like, if you wanna do this everywhere, go read that section, it's right below fr fr.

πŸ’– -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. that's the whole thing. ✨

πŸ’– -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. very convenient, very slay. 🫢

πŸ’– -perl5

use DBIx::Class::Candy::ResultSet -perl5 => v20;

okay so the author is obsessed with the new features in Perl 5.20, and felt it would be nice to remove the boilerplate of doing use feature ':5.20' and just add it to the sugar importer instead. but feel free not to use this. no pressure bestie, it's your resultset πŸ’…


🌈 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'];

ugh, the repetition. the way that it's the same three lines over and over 😭. so:

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] || in base. πŸ‘€ 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. your call, queen.

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 get MyApp::Schema::ResultSet, your experimental will get ['postderef'], and your perl_version will get 18. like, they just get handed the args. that's the whole mechanic. πŸ¦‹


πŸ’œ AUTHOR πŸ’œ

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>


This software is copyright (c) 2024 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.


and that's the tea, bestie πŸ«–βœ¨ this page came to you via perl v5.40.0, dated 2024-11-16, straight out of the User Contributed Perl Documentation. go forth and sugar your resultsets. periodt. πŸ’…πŸ’–

πŸ“¦ where this page comes from