On Wed, May 16, 2012 at 1:11 PM, Brian ROONEY
<[email protected]> wrote:
> Is there any way to I can take control of MX::TD::A such that I can decide
> when to start the dirty tracking? Specifically, below, the attributes in
> Foo::Types::Parameter are populated by reading in a file Foo::Reader->read.
> Only after reading in, I then want to trigger the dirty tracking.
>
> Currently the dirty tracking starts after construction of
> Foo::Types::Parameter which means Foo::Reader::File->param->comment is
> immediately dirty when reading from the file. :(
No it doesn't? But have a look at this:
package Foo::Types::Parameter;
use MooseX::TrackDirty::Attributes;
use Moose;
has 'comment' => (is => "rw", isa => 'Bool', traits => [TrackDirty]);
package main;
my $param = new Foo::Types::Parameter;
$param->comment(1);
$param->comment_is_dirty && warn "1";
$param->comment(0);
$param->comment_is_dirty && warn "2";
$param->meta->get_attribute('comment')->clear_dirty_slot($param);
$param->comment_is_dirty && warn "3";
--
Lars Balker Consult::Perl