MooseX::RememberHistory - Add the ability for attributes to remember their history
package MyClass; use Moose; use MooseX::RememberHistory; has 'some_attr' => ( traits => [ 'RememberHistory' ], isa => 'Num', is => 'rw', default => 0 ); package main; my $obj = MyClass->new; $obj->some_attr(1); my $hist = $obj->some_attr_history; # [ 0, 1 ]
MooseX::RememberHisory provides an attribute trait (
RememberHistory) which will automagically store the values of that attribute in a related ArrayRef on each write to the trait.
When the trait is applied, a history attribute is created. By default, the name of this attribute is the name of the original attribute with the extension
_history (e.g. an attribute named
x would get an additional
This name may be specified manually by the use of the
history_name attribute option. In this case the "SYNOPSIS" example would become:
package MyClass; use Moose; use MooseX::RememberHistory; has 'some_attr' => ( traits => [ 'RememberHistory' ], history_name => 'history_of_some_attr', isa => 'Num', is => 'rw', default => 0 ); package main; my $obj = MyClass->new; $obj->some_attr(1); my $hist = $obj->history_of_some_attr; # [ 0, 1 ]
The author wrote this module to ease the writing of object-oriented differential equation solver framework. When the objects store the history of their own evolution it eases the burden of writing the solver. The solver object only needs to evolve the constituent objects and it need not worry about storing the results; those objects can now do this themselves!
Joel Berger, <email@example.com>
Copyright (C) 2012 by Joel Berger
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.