Search code examples
perlmoose

Perl and Moose: What Moose-based package should I use as replacement for MooseX::Method


To my dismay I noticed that MooseX::Method is no longer maintained and deprecated.

The package MooseX-Method-Signatures is advertized as replacement, but its documentation says: This is ALPHA SOFTWARE. Use at your own risk. Features may change.

<whine>What should I do </whine>


Solution

  • Use MooseX::Declare instead:

    use MooseX::Declare;
    
    class Foo {
        has foo => (isa => "Str", is => "rw", default => "foo");
    
        method bar (Str $bar = "bar") {
            print $self->foo, " says $bar\n";
        }
    }
    
    Foo->new->bar;