DBIx::...mifyGet(3pm)

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

✨ 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 🫢

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