in reply to Why does changing a Moose attributes' properties remove the around modifier

I couldn't replicate your error. I kept getting "around":
use Modern::Perl; package My::Base; use Moose; has 'attr' => (is => 'rw', isa => 'Str', required => 1); around 'attr' => sub { my $orig = shift; my $self = shift; say "I get around..."; return $self->$orig() unless @_; }; package My::Derived; use Moose; extends 'My::Base'; has '+attr' => (required => 0, lazy_build => 1); sub _build_attr { return "default value"; } package My::Inherited; use Moose; extends 'My::Base'; package main; use Test::More; use Test::Exception; use Test::More::Diagnostic; plan tests => 8; my $base = new_ok('My::Base' => [attr => 'constructor value']); cmp_ok($base->attr, 'eq', "constructor value", 'base is correct'); lives_ok {My::Derived->new()} q/derived doesn't require 'attr' at cons +truction/; my $der = new_ok('My::Derived'); cmp_ok($der->attr, 'eq', 'default value', 'derived is correct'); throws_ok {My::Base->new()} qr/Attribute \(attr\) is required/, q/inhe +rited requires 'attr' at construction/;
  • Comment on Re: Why does changing a Moose attributes' properties remove the around modifier
  • Download Code

Replies are listed 'Best First'.
Re^2: Why does changing a Moose attributes' properties remove the around modifier
by mcrose (Beadle) on Jul 18, 2011 at 18:22 UTC

    What perl & moose versions?. I'm getting the same thing (no around in the derived class) under both perl 5.10.0 linux and 5.12.3 win32; both with Moose 2.0010:

    TAP version 13 1..8 ok 1 - The object isa My::Base I get around... ok 2 - base is correct ok 3 - derived doesn't require 'attr' at construction ok 4 - The object isa My::Derived ok 5 - derived is correct ok 6 - inherited requires 'attr' at construction # Looks like you planned 8 tests but ran 6.
Re^2: Why does changing a Moose attributes' properties remove the around modifier
by ikegami (Patriarch) on Jul 18, 2011 at 18:54 UTC

    Stop making incorrect conclusions about other's code after you modified it.

    I couldn't replicate your error.

    Except you did.