I aggree that the default return is not useless, but I also wanted a way to set multiple values in one step. It does not address the inital new/old step that Derek started with but since were talking chained setters, I wrote up MooseX::MutatorAttributes a while ago to allow me to do multiple set's in one step and return $self. It works for me but if any one has any feedback I'd love to hear it.
On Thu, Mar 12, 2009 at 7:29 AM, Chris Prather <perig...@gmail.com> wrote: > On Wed, Mar 11, 2009 at 7:27 PM, Derek Price <de...@ximbiot.com> wrote: >> Actually, I'd be as happy with chained setters - it just bothers me to >> see a useless return value. I'll keep both ideas in mind, thanks! > > It's not *exactly* useless, take the following example: > > > use 5.10.0; > > package Dog; > use Moose; > has name => ( isa => 'Str', is => 'ro' ); > > package PuppyFarm; > use Moose; > use Moose::Util::TypeConstraints; > > class_type 'Dog'; > coerce "Dog" => from 'Str' => via { Dog->new(name => $_) }; > > has dog => ( isa => 'Dog', is => 'rw', coerce => 1); > > > package main; > > my $o = PuppyFarm->new(); > my $dog = $o->dog("Spot"); > say ref $dog; > say $dog->dump; > > > The value stored isn't always the value submitted. > -- benh~ http://three.sentenc.es/