DBIx::...::Util(3pm)
π DBIx::...::Util β the manual, but make it cute β¨
okay bestie, so this is DBIx::...::Util(3pm), and it lives in the User Contributed Perl Documentation corner of your system. it's a lil grab-bag of helper utilities for DBIx::Class components, and honestly? it's giving "backstage pass for people building the schema." let's go π«Ά
πΈ NAME πΈ
DBIx::Class::Helpers::Util β helper utilities for DBIx::Class components. no cap, that's the whole vibe.
β¨ SYNOPSIS β¨
here's the whole thing, verbatim, because you deserve the real deal:
use DBIx::Class::Helpers::Util ':all';
my ($namespace, $class) = get_namespace_parts('MyApp:Schema::Person');
is $namespace, 'MyApp::Schema';
is $class, 'Person';
if (is_load_namespaces('MyApp::Schema::Result::Person')) {
print 'correctly structured project';
}
if (is_not_load_namespaces('MyApp::Schema::Person')) {
print 'incorrectly structured project';
}
if (assert_similar_namespaces('MyApp::Schema::Person', 'FooApp::Schema::People')) {
print 'both projects are structured similarly';
}
if (assert_similar_namespaces('MyApp::Schema::Result::Person', 'FooApp::Schema::Result::People')) {
print 'both projects are structured similarly';
}
# in a resultset
sub search {
my ($self, $search, $attrs) = @_;
$attrs->{order_by} = order_by_visitor($attrs->{order_by}, sub {
my $field = shift;
return 'foo_bar' if $field eq 'foo.bar';
return $field;
}) if $attrs && $attrs->{order_by};
$self->next::method($search, $attrs);
}
# in schema
sub connection {
my $self = shift;
my $args = normalize_connect_info(@_);
$args->{quote_names} = 1;
$self->next::method($args)
}
see how much ground that covers? order_by glow-ups, namespace surgery, connect info normalization β she does it all π
π¦ DESCRIPTION π¦
it's a collection of various helper utilities for DBIx::Class stuff. and like, probably only useful for components β so if you're not writing components, this is not your main character moment, and that's okay π
π EXPORTS π
π« order_by_visitor
this function lets you easily transform "order_by" clauses. see "SYNOPSIS" for the example β it's literally right up there, go look, i'll wait π
π« get_namespace_parts
returns the namespace and class name of a package. see "SYNOPSIS" for example.
π« is_load_namespaces
returns true if a package is structured in a way that would work for load_namespaces. see "SYNOPSIS" for example.
π« is_not_load_namespaces
returns true if a package is structured in a way that would not work for load_namespaces. see "SYNOPSIS" for example. yes she's the mirror twin of the one above, obsessed with the symmetry honestly β¨
π« assert_similar_namespaces
dies if both packages are structured in the same way. the same means both are load_namespaces or both are not. see "SYNOPSIS" for example.
β οΈ bestie read that again β it dies when they match. that's what the doc says, that's what we're saying, no editorializing here, just don't let it jump scare you π
π« normalize_connect_info
takes all of the various and interesting forms that can be passed to connect and normalizes them into the final and simplest form, a single hashref. one hashref to rule them all, iconic behavior π
π AUTHOR π
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> β shoutout to fREW, doing the lord's work fr fr π
π COPYRIGHT AND LICENSE π
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 whole page, bestie!! this beauty was brought to you by perl v5.40.0, dated 2024-11-16 β genuinely a whole moment in time ππ slay, bye, go write some components π¦β¨
π¦ where this page comes from
- debian trixie: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms