The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MooX::Emulate::Class::Accessor::Fast - Emulate Class::Accessor::Fast behavior using Moo attributes.

SYNOPSYS

  package MyClass;
  use Moo;
  
  with 'MooX::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/);

DESCRIPTION

This module attempts to emulate the behavior of Class::Accessor::Fast as accurately as possible using the Moo attribute system. The public API of Class::Accessor::Fast is wholly supported, but the private methods are not. If you are only using the public methods (as you should) migration should be a matter of switching your use base line to a with line.

This module is a straight fork-and-port of MooseX::Emulate::Class::Accessor::Fast version 0.00903 for Moo. All tests from the original Moose module pass or were, as little as possible, modified to pass. Much of the documentation, code concepts, and tests are just straight copied from the original module. The core functionality, though, had to be a complete rewrite for Moo.

While we have attempted to emulate the behavior of Class::Accessor::Fast as closely as possible bugs may still be lurking in edge-cases.

BEHAVIOR

Simple documentation is provided here for your convenience, but for more thorough documentation please see Class::Accessor::Fast and Class::Accessor.

METHODS

mk_accessors

  __PACKAGE__->mk_accessors( @field_names );

See "mk_accessors" in Class::Accessor.

mk_ro_accessors

  __PACKAGE__->mk_ro_accessors( @field_names );

See "mk_ro_accessors" in Class::Accessor.

mk_wo_accessors

  __PACKAGE__->mk_wo_accessors( @field_names );

See "mk_wo_accessors" in Class::Accessor.

follow_best_practice

  __PACKAGE__->follow_best_practice();

See "follow_best_practice" in Class::Accessor.

mutator_name_for

  sub mutator_name_for { 'change_' . $_[1] }

See "MAKING ACCESSORS" in Class::Accessor.

accessor_name_for

  sub accessor_name_for { 'retrieve_' . $_[1] }

See "MAKING ACCESSORS" in Class::Accessor.

set

  $object->set( $field => $value );

See "set" in Class::Accessor.

get

  my $value = $object->get( $field );
  my @values = $object->get( $field1, $field2 );

See "get" in Class::Accessor.

make_accessor

  my $coderef = $class->make_accessor( $field );

See "make_accessor" in Class::Accessor.

make_ro_accessor

  my $coderef = $class->make_ro_accessor( $field );

See "make_ro_accessor" in Class::Accessor.

make_wo_accessor

  my $coderef = $class->make_wo_accessor( $field );

See "make_wo_accessor" in Class::Accessor.

SEE ALSO

Moo, Class::Accessor, Class::Accessor::Fast, MooseX::Emulate::Class::Accessor::Fast

AUTHORS

Aran Clary Deltac <bluefeet@gmail.com>

Graham Knop <haarg@haarg.org>

Mohammad S Anwar <mohammad.anwar@yahoo.com>

Original code, tests, and documentation taken from MooseX::Emulate::Class::Accessor::Fast. Thanks!

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.