MooX::SingleArg(3pm)

πŸ“¦
version 0.08 Β· 4 versions
, in debian bookworm, ubuntu jammy

πŸ’– 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::BuildArgs
  • MooX::BuildArgsHooks
  • MooX::MethodProxyArgs
  • MooX::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