| Fey-ORM-Mock documentation | Contained in the Fey-ORM-Mock distribution. |
Fey::ORM::Mock::Recorder - Records the history of changes for a class
version 0.05
This object is used to store a record of the changes for each class.
This class provides the following methods:
Returns a new recorder object.
This method takes a set of parameters which will be passed directly to
Fey::ORM::Mock::Action->new_action(). Then it stores the action.
Given a class name, this returns a list of stored actions for that class, from least to most recent.
Clears the record of actions for the class
Clears the records for all classes.
Dave Rolsky <autarch@urth.org>
This software is Copyright (c) 2010 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0
| Fey-ORM-Mock documentation | Contained in the Fey-ORM-Mock distribution. |
package Fey::ORM::Mock::Recorder; BEGIN { $Fey::ORM::Mock::Recorder::VERSION = '0.05'; } use strict; use warnings; use Fey::ORM::Mock::Action; use Moose; has '_actions' => ( is => 'ro', isa => 'HashRef[ArrayRef[Fey::ORM::Mock::Action]]', default => sub { {} }, ); sub record_action { my $self = shift; my $action = Fey::ORM::Mock::Action->new_action(@_); $self->_actions()->{ $action->class() } ||= []; push @{ $self->_actions()->{ $action->class() } }, $action; return; } sub actions_for_class { my $self = shift; my $class = shift; return @{ $self->_actions()->{$class} || [] }; } sub clear_class { my $self = shift; my $class = shift; $self->_actions()->{$class} = []; } sub clear_all { my $self = shift; for my $class ( keys %{ $self->_actions() } ) { $self->clear_class($class); } } no Moose; __PACKAGE__->meta()->make_immutable(); 1; # ABSTRACT: Records the history of changes for a class
__END__