-6

I need an explanation of this one liner. Is this only calling the set() method? Or something else?

Thanks for the help!

has 'shape' => ( is => 'rw' );

The object is using MooseX::FollowPBP.

Ashley
  • 413
  • 3
  • 8
  • 17

1 Answers1

2

This is basic Moose syntax. has is a Moose keyword that defines an attribute in your class. The attributes name is shape, and it is read-write.

It's documented in multiple places.

has $name|@$names => %options

This will install an attribute of a given $name into the current class. If the first parameter is an array reference, it will create an attribute for every $name in the list. The %options will be passed to the constructor for Moose::Meta::Attribute (which inherits from Class::MOP::Attribute), so the full documentation for the valid options can be found there.

The MooseX::FollowPBP has nothing to do with it directly. It just changes the behavior of Moose, to turn the default accessor $obj->shape into $obj->get_shape and $obj->set_shape, following the suggestion of Damian Conway in his book Perl Best Practices.

Community
  • 1
  • 1
simbabque
  • 53,749
  • 8
  • 73
  • 136