xslate / p5-Mouse

Lightweight class builder for Perl, as a subset of Moose
https://metacpan.org/release/Mouse
Other
46 stars 32 forks source link

Make trigger pass in the old value for Moose compatibility. #6

Closed schwern closed 11 years ago

schwern commented 11 years ago

Moose docs say...

       trigger => $code
           The trigger option is a CODE reference which will be called
           after the value of the attribute is set. The CODE ref is passed
           the instance itself, the updated value, and the original value
           if the attribute was already set.

The XS code could probably be written better without the has_old_value sentinel, but I don't know how.

I pulled in t/attributes/attribute_triggers.t from the latest Moose as it has compatible trigger tests. They switched from Test::Exception to Test::Fatal so I've added Test::Fatal as an include.

For rt.cpan.org 76880