SPOPS::Loopback - Simple SPOPS class used for testing rules and other goodies


    use SPOPS::Initialize;

    my %config = (
      test => {
         class    => 'LoopbackTest',
         isa      => [ qw( SPOPS::Loopback ) ],
         field    => [ qw( id_field field_name ) ],
         id_field => 'id_field',
    SPOPS::Initialize->process({ config => \%config });
    my $object = LoopbackTest->new;


This is a simple SPOPS class that returns success for all operations. The serialization methods (save(), fetch(), fetch_group() and remove()) all call the pre/post action methods just like any other objects, so it is useful for testing out rules.


fetch( $id )

Returns a new object initialized with the ID $id, calling the pre/post_fetch_action() methods first. If the object has been previously saved we pull it from the in-memory storage, otherwise we return a new object initialized with $id.

fetch_group( \%params )

Returns an arrayref of previously saved objects. If no objects have been saved, it returns an arrayref of new objects initialized with numeric IDs.

We grab the 'where' clause out of \%params but do only some rudimentary parsing to return previously stored objects. (Patches welcome.)


Returns the object you called the method on. If this is an unsaved object (if it has not been fetched or saved previously), we call pre_fetch_id() and post_fetch_id() to trigger any key-generation actions.

Saved and unsaved objects both have pre/post_save_action() methods called.

This also stores the object in-memory so you can call fetch() on it later.


Calls the pre/post_remove_action() and removes the object from the in-memory storage.

peek( $id, $field )

Peeks into the in-memory store for the value of $field for object $id. Must be called as class method.




Copyright (c) 2001-2004, inc.. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Chris Winters <>