Adds a class and all its surclasses into this generator. Sets the default values of PERSIST hash is they miss.
Generates the references methods in the class from the reference hash of the class.
Let a reference called foo pointing to an Bar object in the persist hash. The class MUST have a foo attribute that is dedicated to a Bar object.
This method will implement a foo method for the class that fetch the perl object from the database on demand ( accessor behaviour) Or just set the Foo object and check it is for the right class and save it if its not.
method template: for a reference named 'foo' to a Bar object.
sub foo_O{ my ($self, $value ) = @_ ; if( $value ){ if( ! $value->isa('Bar')){ confess("Bad class") ;} $self->{'foo_Bar'} = $value ; my $dbid = $value->{'_dbid_'} ; if ( ! defined $dbid ){ confess("Object $value is not saved"); } $self->foo($dbid) return $value ; }
# if foo unset, got to fetch it. my $dbid = $self->foo(); # If no dbid is set, theres no object to fetch if( ! defined $dbid ) { return undef ;} # Is the object is allready fetch if( defined $self->{'foo_O'} ) { return $self->{'foo_O'} ; } # really got to fetch return $self->{'foo_O'} = Factory->instance()->fetchObject('Bar',$dbid);
}
Sets default values for missing values in PERSIST hash for a class.
Usage: my $class = .... ; # the persistent class name my $h = .... ; # The PERSIST HASH of the class $class;
$sg->setDefault($class,$h);
Delete all the tables from the schema.
Implements the schema into the database. If $override is true, call deleteSchema before.
usage:
$sg->updateSchema([1]);
To install SLOOPS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SLOOPS
CPAN shell
perl -MCPAN -e shell install SLOOPS
For more information on module installation, please visit the detailed CPAN module installation guide.