Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
SPOPS::Tool::CreateOnlUser Contributed Perl DocumentSPOPS::Tool::CreateOnly(3)

NAME
       SPOPS::Tool::CreateOnly - Make a	particular object create-only -- it
       cannot be updated

SYNOPSIS
	# Load information with	create-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::CreateOnly' ],
	};
	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 [This::Class] 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!

DESCRIPTION
       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.

METHODS
       behavior_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.

BUGS
       None known.

TO DO
       Nothing known.

SEE ALSO
       SPOPS::Manual::ObjectRules

       SPOPS::ClassFactory

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

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

AUTHORS
       Chris Winters <chris@cwinters.com>

perl v5.32.1			  2004-06-02	    SPOPS::Tool::CreateOnly(3)

NAME | SYNOPSIS | DESCRIPTION | METHODS | BUGS | TO DO | SEE ALSO | COPYRIGHT | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=SPOPS::Tool::CreateOnly&sektion=3&manpath=FreeBSD+13.0-RELEASE+and+Ports>

home | help