MouseX...CodeRef(3pm)
π NAME π
MouseX::NativeTraits::CodeRef β bestie, it's a helper trait for CodeRef attributes. That's the whole vibe. It's a page from the User Contributed Perl Documentation corner of the manual, and it's giving "small but mighty." β¨
π SYNOPSIS π
okay so picture this: you've got a class, and you want an attribute that is literally a function. Watch:
package Foo;
use Mouse;
has 'callback' => (
traits => ['Code'],
is => 'ro',
isa => 'CodeRef',
default => sub { sub { print "called" } },
handles => {
call => 'execute',
},
);
my $foo = Foo->new;
$foo->call; # prints "called"
So traits => ['Code'] is you opting into this trait, isa => 'CodeRef' keeps it honest, and the handles bit maps a method name (call) onto an operation this trait hands you (execute). Then $foo->call just... runs the thing. And it prints called. No cap. π
πΈ DESCRIPTION πΈ
This provides operations on coderef attributes. That's it, that's the whole description, and honestly? Iconic minimalism. It exists so your coderef attributes can do stuff instead of just sitting there being a blessed reference. π¦
β¨ PROVIDED METHODS β¨
execute(@args)β Calls the coderef with the given args. Yeah, that's it. You pass it args, it feeds them straight into your coderef. Simple, clean, does exactly what it says on the tin. π«Ά
π METHODS π
these are the methods, no notes:
metamethod_provider_classhelper_type
π SEE ALSO π
MouseX::NativeTraitsβ the main character. Go read that one next, fr fr. π
and that's the whole page, bestie π this one came from the User Contributed Perl Documentation, version perl v5.34.0, dated 2022-06-16, and it's filed under MouseX...CodeRef(3pm) β go forth and call your coderefs πβ¨π
π¦ where this page comes from
- debian bookworm: libmousex-nativetraits-perl 1.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmousex-nativetraits-perl 1.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmousex-nativetraits-perl 1.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmousex-nativetraits-perl 1.09-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmousex-nativetraits-perl 1.09-3 Β· 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