Catman...areTest(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay so bestie, this is Catmandu::Fix::Condition::SimpleCompareTest β€” a 3pm perl manual page, no cap ✨

it's the base class you inherit from when you wanna make compare conditionals without doing all the boring scaffolding yourself. it exists purely to make your life easier, and honestly? it ate. πŸ’…


🌸 SYNOPSIS 🌸

here's the whole vibe, literally copy-paste energy:

package Catmandu::Fix::Condition::has_equal_type

use Catmandu::Sane;
use Moo;
use Catmandu::Fix::Has;

has path  => (fix_arg => 1);
has path2 => (fix_arg => 1);

with 'Catmandu::Fix::Condition::SimpleCompareTest';

sub emit_test {
    my ($self, $var, $var2, $fixer) = @_;
    "is_value(${var}) && is_value(${var2}) && ref ${var} eq ref ${var2}";
}

1;

# Now you can write in your fixes
has_equal_type(my_field_1,my_field_2)  # True when my_field_1 and my_field_2 have
                                       # the same refence type (both scalas, arrays, hashes)

so the way this works is 🫢 you use Catmandu::Sane;, use Moo;, and use Catmandu::Fix::Has;, then declare your args with has path => (fix_arg => 1); and has path2 => (fix_arg => 1);. then you pull in the base class with with 'Catmandu::Fix::Condition::SimpleCompareTest'; and write your very own emit_test sub that takes ($self, $var, $var2, $fixer) and returns the test string. then slap a 1; at the bottom so perl is happy and you're done. iconic. πŸ‘‘

once that's built you get to use it in your fixes like has_equal_type(my_field_1,my_field_2), which is True when my_field_1 and my_field_2 have the same refence type (both scalas, arrays, hashes). yes we're keeping the typo, it's part of the lore now. πŸ’€


πŸ¦‹ SEE ALSO πŸ¦‹

  • Catmandu::Fix::Condition::SimpleAllTest
  • Catmandu::Fix::Condition::SimpleAnyTest

ngl, this is a base class, so you don't call it directly β€” you with it and let it carry you. main character energy only. ✨

k bye bestie, go build something cute πŸŽ€

this page ships with perl v5.40.1, dated 2026-01-24 β€” mwah, xoxo πŸ’œ

πŸ“¦ where this page comes from