MooX::SingleArg(3pm)
π MooX::SingleArg π
okay bestie, so like β this is MooX::SingleArg, a lil Perl module (lives in the User Contributed Perl Documentation section of your man pages, iykyk) that supports single-argument instantiation. yes that means what you think it means. you get to say Foo->new('goo') instead of wrestling with a whole hashref. iconic behaviour fr fr. π
β¨ SYNOPSIS β¨
like, just look at this. it's giving effortless:
package Foo;
use Moo;
with 'MooX::SingleArg';
Foo->single_arg('bar');
has bar => ( is=>'ro' );
my $foo = Foo->new( 'goo' );
print $foo->bar(); # goo
no cap, that's the whole vibe. you pass 'goo', you get goo back. slay. π
π¦ CLASS ARGUMENTS π¦
single_arg
__PACKAGE__->single_arg( 'foo' );
use this to declare the "init_arg" of the single argument. that's it, that's the job. tell it which attribute is the one getting fed by that lone little arg. πΈ
force_single_arg
__PACKAGE__->force_single_arg( 1 );
this one causes single-argument processing to happen even if a hashref is passed in as the single argument. so like, normally a hashref gets treated as a hashref β but with this turned on, nope, it still goes through the single-argument pipeline. periodt. π
π CLASS METHODS π
has_single_arg
returns true if "single_arg" has been called. that's the whole method. a little vibe check for your class. β¨
π SEE ALSO π
MooX::BuildArgsMooX::BuildArgsHooksMooX::MethodProxyArgsMooX::Rebuild
go read them, they're all part of the same friend group π«Ά
π SUPPORT π
see "SUPPORT" in MooX::BuildArgs. π
π§ AUTHORS π§
see "AUTHORS" in MooX::BuildArgs. π
β LICENSE β
see "LICENSE" in MooX::BuildArgs. π
lowkey important: everything about support, authors and license lives over in MooX::BuildArgs, so don't come looking for it here bestie, just click through π
and that's the whole page!! π this was perl v5.30.3, dated 2020-09-12, and it's the MooX::SingleArg(3pm) man page β love that for us. mwah, go write some single-arg constructors. β¨π
πΈ
π¦ where this page comes from
- debian bookworm: libmoox-buildargs-perl 0.08-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libmoox-buildargs-perl 0.08-2 Β· 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