01 Apr 2012 18:00:32 UTC
- Distribution: MooseX-RememberHistory
- Module version: 0.001
- Source (raw)
- Browse (raw)
- How to Contribute
- Clone repository
- Issues (0)
- Testers (479 / 1 / 0)
- KwaliteeBus factor: 1
- % Coverage
- License: perl_5
- Activity24 month
- Download (9.81KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionJBERGER Joel Berger
- THE HISTORY ATTRIBUTE
- SEE ALSO
- SOURCE REPOSITORY
- COPYRIGHT AND LICENSE
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
xwould get an additional
This name may be specified manually by the use of the
history_nameattribute 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!
Moose - A postmodern object system for Perl 5
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.
Module Install Instructions
To install MooseX::RememberHistory, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install MooseX::RememberHistory
For more information on module installation, please visit the detailed CPAN module installation guide.