View on
MetaCPAN
search.cpan.org is shutting down
For details read Perl NOC. After June 25th this page will redirect to MetaCPAN.org
Joel Berger > MooseX-RememberHistory-0.001 > MooseX::RememberHistory

Download:
MooseX-RememberHistory-0.001.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.001   Source  

NAME ^

MooseX::RememberHistory - Add the ability for attributes to remember their history

SYNOPSIS ^

 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 ]

DESCRIPTION ^

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.

THE HISTORY ATTRIBUTE ^

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 x_history attribute).

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 ]

MOTIVATION ^

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!

SEE ALSO ^

SOURCE REPOSITORY ^

http://github.com/jberger/MooseX-RememberHistory

AUTHOR ^

Joel Berger, <joel.a.berger@gmail.com>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: