Rose::DB::Object::Util - Utility functions for use in Rose::DB::Object subclasses and method makers.
package MyDBObject; use Rose::DB::Object::Util qw(:all); use Rose::DB::Object; our @ISA = qw(Rose::DB::Object); ... sub whatever { my($self) = shift; ... if(is_loading($self)) { ... set_state_in_db($self); } ... }
Rose::DB::Object::Util provides functions that are useful for developers who are subclassing Rose::DB::Object or otherwise extending or modifying its behavior.
Rose::DB::Objects have some awareness of their current situation. Certain optimizations rely on this awareness. For example, when loading column values directly from the database, there's no reason to validate the format of the data or immediately "inflate" the values. The is_loading function will tell you when these steps can safely be skipped.
Similarly, it may be useful to set these state characteristics in your code. The set_sate_* functions provide that ability.
set_sate_*
Rose::DB::Object::Util does not export any function names by default.
Rose::DB::Object::Util
The 'get_state' tag:
use Rose::DB::Object::Util qw(:get_state);
will cause the following function names to be imported:
is_in_db() is_loading() is_saving()
The 'set_state' tag:
use Rose::DB::Object::Util qw(:set_state);
set_state_in_db() set_state_loading() set_state_saving()
The 'unset_state' tag:
use Rose::DB::Object::Util qw(:unset_state);
unset_state_in_db() unset_state_loading() unset_state_saving()
The 'all' tag:
use Rose::DB::Object::Util qw(:all);
is_in_db() is_loading() is_saving() set_state_in_db() set_state_loading() set_state_saving() unset_state_in_db() unset_state_loading() unset_state_saving()
Given the Rose::DB::Object-derived object OBJECT, returns true if the object was loaded from, or has ever been saved into, the database, or false if it has not.
Given the Rose::DB::Object-derived object OBJECT, returns true if the object is currently being loaded, false otherwise.
Given the Rose::DB::Object-derived object OBJECT, returns true if the object is currently being saved, false otherwise.
Mark the Rose::DB::Object-derived object OBJECT as having been loaded from or saved into the database at some point in the past.
Indicate that the Rose::DB::Object-derived object OBJECT is currently being loaded from the database.
Indicate that the Rose::DB::Object-derived object OBJECT is currently being saved into the database.
Mark the Rose::DB::Object-derived object OBJECT as not having been loaded from or saved into the database at some point in the past.
Indicate that the Rose::DB::Object-derived object OBJECT is not currently being loaded from the database.
Indicate that the Rose::DB::Object-derived object OBJECT is not currently being saved into the database.
John C. Siracusa (siracusa@mindspring.com)
Copyright (c) 2006 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Rose::DB::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Rose::DB::Object
CPAN shell
perl -MCPAN -e shell install Rose::DB::Object
For more information on module installation, please visit the detailed CPAN module installation guide.