MooseX...::Fast(3pm)

πŸ“¦
version 0.009032 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– MooseX::Emulate::Class::Accessor::Fast β€” the manual page, but make it cute πŸ’–

perl v5.36.0 Β· User Contributed Perl Documentation Β· MooseX...::Fast(3pm)

okay bestie, sit down, hydrate, because we're doing MooseX::Emulate::Class::Accessor::Fast and honestly? it's giving glow-up arc. πŸ¦‹


✨ NAME ✨

MooseX::Emulate::Class::Accessor::Fast β€” it emulates Class::Accessor::Fast behavior using Moose attributes. that's the whole vibe. no cap. πŸ’…


🌸 SYNOPSYS 🌸

(yes the section is literally spelled "SYNOPSYS", we respect the original's choices πŸŽ€)

package MyClass;
use Moose;

with 'MooseX::Emulate::Class::Accessor::Fast';

#fields with readers and writers
__PACKAGE__->mk_accessors(qw/field1 field2/);
#fields with readers only
__PACKAGE__->mk_ro_accessors(qw/field3 field4/);
#fields with writers only
__PACKAGE__->mk_wo_accessors(qw/field5 field6/);

look at that. three lines and you have a whole personality. 😭


πŸ’œ DESCRIPTION πŸ’œ

so this module is out here attempting to emulate the behavior of Class::Accessor::Fast as accurately as possible using the Moose attribute system. the public API of Class::Accessor::Fast is wholly supported β€” like, all of it β€” but the private methods are NOT. πŸ™ˆ

and if you're only using the public methods (which, bestie, you should be, that's the whole point), migration is genuinely just switching your use base line to a with line. that's it. that's the glow-up. iconic. πŸ‘‘

ngl, the author says they've attempted to emulate the behavior of Class::Accessor::Fast as closely as possible β€” but bugs may still be lurking in edge-cases. so like. edge cases. be aware. πŸ’€

πŸ¦‹ BEHAVIOR πŸ¦‹

there's simple documentation right here for your convenience, but for the thorough stuff you're gonna want to go read Class::Accessor::Fast and Class::Accessor. go on, we'll wait. 🫢

πŸ” A note about introspection πŸ”

please note: at this time, the is flag attribute is not being set. 😭

so if you're trying to figure out the reader and writer methods using introspection in later versions of Class::MOP ( > 0.38 ), please use the get_read_method and get_write_method methods in Class::MOP::Attribute. example time, slay:

# with Class::MOP <= 0.38
my $attr = $self->meta->find_attribute_by_name($field_name);
my $reader_method = $attr->reader || $attr->accessor;
my $writer_method = $attr->writer || $attr->accessor;

# with Class::MOP > 0.38
my $attr = $self->meta->find_attribute_by_name($field_name);
my $reader_method = $attr->get_read_method;
my $writer_method = $attr->get_write_method;

πŸ‘‘ METHODS πŸ‘‘

⭐ BUILD $self %args

Change the default Moose class building to emulate the behavior of C::A::F and store arguments in the instance hashref. periodt. πŸ’…

⭐ mk_accessors @field_names

Create read-write accessors. An attribute named $field_name will be created. the name of the reader and writer methods will be determined by the return value of accessor_name_for and mutator_name_for, which by default return the name passed unchanged. πŸŽ€

and if the accessor and mutator names are equal, the accessor attribute will be passed to Moose; otherwise the reader and writer attributes will be passed. please see Class::MOP::Attribute for more information. iykyk. 🌸

⭐ mk_ro_accessors @field_names

Create read-only accessors.

⭐ mk_ro_accessors @field_names

Create write-only accessors.

okay so β€” this is literally what the page says. the second one is printed as mk_ro_accessors @field_names and its description says "Create write-only accessors." the synopsis up top uses mk_wo_accessors for writer-only fields. we are not editing the sacred text, we're just showing you exactly what it says. πŸ’€

⭐ follow_best_practices

Preface readers with 'get_' and writers with 'set_'. See original Class::Accessor documentation for more information. πŸŽ€

⭐ mutator_name_for

⭐ accessor_name_for

See original Class::Accessor documentation for more information.

⭐ set

See original Class::Accessor documentation for more information.

⭐ get

See original Class::Accessor documentation for more information.

⭐ meta

See Moose::Meta::Class.


🌈 SEE ALSO 🌈

  • Moose
  • Moose::Meta::Attribute
  • Class::Accessor
  • Class::Accessor::Fast
  • Class::MOP::Attribute
  • MooseX::Adopt::Class::Accessor::Fast

go read all of them. bestie homework. πŸ“šβœ¨


🫢 AUTHORS 🫢

Guillermo Roditi (groditi) <groditi@cpan.org>

with contributions from, and we are obsessed with them:

  • Tomas Doran (t0m) <bobtfish@bobtfish.net>
  • Florian Ragwitz (rafl) <rafl@debian.org>

πŸŽ€ LICENSE πŸŽ€

You may distribute this code under the same terms as Perl itself. πŸ’–


and that's the page, bestie!! πŸ¦‹βœ¨ this was perl v5.36.0, dated 2022-12-12, and it's the MooseX...::Fast(3pm) manual. go forth and migrate your use base line to a with line. you got this. mwah. πŸ’…πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from