SPOPS::Tool::ReadOnly - Make a particular object read-only


SPOPS documentation  | view source Contained in the SPOPS distribution.

Index


NAME

Top

SPOPS::Tool::ReadOnly - Make a particular object read-only

SYNOPSIS

Top

 # Load information with read-only rule

 my $spops = {
    class               => 'This::Class',
    isa                 => [ 'SPOPS::DBI' ],
    field               => [ 'email', 'language', 'country' ],
    id_field            => 'email',
    base_table          => 'test_table',
    rules_from          => [ 'SPOPS::Tool::ReadOnly' ],
 };
 SPOPS::Initialize->process({ config => { test => $spops } });

 # Fetch an object, modify it... 
 my $object = This::Class->fetch( 45 );
 $object->{foo} = "modification";

 # Trying to save the object throws an error:
 # "This::Class is read-only; no changes allowed"
 eval { $object->save };

DESCRIPTION

Top

This is a simple rule to ensure that save() and remove() calls to a particular class do not actually do any work. Instead they just result in a warning that the class is read-only.

METHODS

Top

behavior_factory()

Installs the behavior during the class generation process.

generate_persistence_methods()

Generates save() and remove() methods that just throw exceptions.

BUGS

Top

None known.

TO DO

Top

Nothing known.

SEE ALSO

Top

SPOPS::Manual::ObjectRules (SPOPS::Manual::ObjectRules)

SPOPS::ClassFactory

COPYRIGHT

Top

AUTHORS

Top

Chris Winters <chris@cwinters.com>


SPOPS documentation  | view source Contained in the SPOPS distribution.