in reply to Re^6: Why does changing a Moose attributes' properties remove the around modifier
in thread Why does changing a Moose attributes' properties remove the around modifier

Yeah, that's a much better way of behaving. I'd missed the documentation that mentioned 'init_arg'. I do need to read through the Class::MOP stuff some time to make sure I'm not missing out on things like this. Thanks for the pointer.

  • Comment on Re^7: Why does changing a Moose attributes' properties remove the around modifier

Replies are listed 'Best First'.
Re^8: Why does changing a Moose attributes' properties remove the around modifier
by ikegami (Patriarch) on Jul 20, 2011 at 18:46 UTC

    It's possible to do without init_arg (which I didn't know about for the longest time either), but it's less clear.

    for my $field (qw( server peer monitor netlog )) { my $object = "${field}_object"; has $field => ( reader => $object, isa => 'NetAddr::IP', coerce => 1, required => 1, handles => { $field => sub { $_[0]->$object->addr }, }, ); }