Subject: | Want to change what accessors to return $self on set |
Test::Builder2 wants to work like this:
my $result = $Builder->ok(1 + 1, "Simple addition")
->todo("Oh god, everything is so broken!");
Which is shorthand for this:
my $result = $Builder->ok(1 + 1, "Simple addition");
$result->todo("Oh god, everything is so broken");
This means the todo() accessor, when setting, has to return back $self,
not the new value. There doesn't appear to be any way to do this in
Mouse, so I had to stop using it for Test::Builder2::Result and that sucked.
http://github.com/schwern/test-more/commit/4977dbfdd79266d83ab3bf53bd91d3f09cd3a2b0
I normally don't like this style, but it solves a bunch of design
problems in this case. I know plenty of others do like this style. It
sucks that using or not using Mouse hinges on that decision. Can there
be a flag to has() or something to change the return style of accessors?
Or is there another elegant work around?