SPOPS::Tool::CreateOnly

SPOPS::Tool::CreateOnly is a Perl module to make a particular object create-only -- it cannot be updated.
Download

SPOPS::Tool::CreateOnly Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Chris Winters
  • Publisher web site:
  • http://search.cpan.org/~cwinters/SPOPS-0.87/SPOPS/SQLInterface.pm

SPOPS::Tool::CreateOnly Tags


SPOPS::Tool::CreateOnly Description

SPOPS::Tool::CreateOnly is a Perl module to make a particular object create-only -- it cannot be updated. SPOPS::Tool::CreateOnly is a Perl module to make a particular object create-only -- it cannot be updated.SYNOPSIS # Load information with create-only rule my $spops = { class => 'This::Class', isa => , field => , id_field => 'email', base_table => 'test_table', rules_from => , }; SPOPS::Initialize->process({ config => { test => $spops } }); # Fetch an object and try to modify it... my $object = This::Class->fetch( 'prez@whitehouse.gov' ); $object->{country} = "Time/Warnerland"; # Trying to save the object throws an error: # "Objects in can only be inserted, not updated. No changes made" eval { $object->save }; if ( $@ ) { print $@ } # Instantiate a new object and try to save it... my $new_object = This::Class->new({ email => 'foo@bar.com', language => 'lv', country => 'Freedonia' }); eval { $new_object->save() }; # ...works as normal, object is saved. Hooray!This is a simple rule to ensure that calls to save() on an already-saved object do nothing. Calling save() on a new (unsaved) object works as normal. Thus, you have create-only objects.METHODSbehavior_factory()Installs the behavior during the class generation process.generate_persistence_methods()Generates a save() method that issues a warning and a no-op when called on a saved object. Requirements: · Perl


SPOPS::Tool::CreateOnly Related Software