DBIx::...mifyGet(3pm)
β¨ NAME β¨
DBIx::Class::Helper::Row::NumifyGet β bestie, this one forces numeric "context" on your numeric columns π
(also known as DBIx::...mifyGet(3pm) if you caught it in the wild, and it lives in the User Contributed Perl Documentation section, so you know it's the people's choice π«Ά)
πΈ SYNOPSIS πΈ
okay so here's the whole vibe, copy it exactly bestie:
package MyApp::Schema::Result::Foo_Bar;
__PACKAGE__->load_components(qw{Helper::Row::NumifyGet Core});
__PACKAGE__->table('Foo');
__PACKAGE__->add_columns(
foo => {
data_type => 'integer',
is_nullable => 0,
is_numeric => 1,
},
);
sub TO_JSON {
return {
foo => $self->foo, # this becomes 0 instead of "0" due to context
}
}
see that comment? this becomes 0 instead of "0" due to context β that's the whole entire point. the number 0 and the string "0" are NOT the same thing and JSON does not care about your feelings, so this helper steps in. iconic behavior honestly π
π METHODS π
get_column
This is the method that "converts" the values. It just checks for is_numeric and if that is true it will numify the value.
ngl it's giving bouncer at the club β checks is_numeric, and if you're on the list you get numified π
if you're not, nothing happens to you, carry on.
get_columns
This method also "converts" values, but this one is called a lot more rarely. Again, It just checks for is_numeric and if that is true it will numify the value.
same energy, same is_numeric check, same numify, just way less often β it's the group-chat lurker of methods fr fr π¦
π AUTHOR π
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
king behavior, we stan π«Ά
π 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.
so yes bestie you can remix it, just keep the same terms as Perl 5 itself β periodt π
and that's the whole page π this was perl v5.40.0, dated 2024-11-16, filed under DBIx::...mifyGet(3pm) β go numify something, mwah πβ¨
π¦ 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