|
From: Chris W. <la...@us...> - 2001-11-27 12:07:57
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv15542/OpenInteract
Modified Files:
Page.pm
Log Message:
separate out the storage classes so we don't have the several if/then ladders
Index: Page.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/pkg/base_page/OpenInteract/Page.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Page.pm 2001/11/26 06:55:14 1.5
--- Page.pm 2001/11/27 12:07:52 1.6
***************
*** 13,16 ****
--- 13,22 ----
+ my %STORAGE_CLASS = (
+ database => 'OpenInteract::Page::Database',
+ file => 'OpenInteract::Page::File',
+ http => 'OpenInteract::Page::Http',
+ );
+
########################################
# CLASS METHODS
***************
*** 69,83 ****
# Fetch the content from either the filesystem or database, depending.
! sub content {
my ( $self ) = @_;
! if ( $self->{storage} eq 'file' ) {
! return $self->{content} = OpenInteract::Page::File::load( $self );
! }
! if ( $self->{storage} eq 'database' ) {
! return $self->{content} = OpenInteract::Page::Database::load( $self );
! }
! if ( $self->{storage} eq 'http' ) {
! return $self->{content} = OpenInteract::Page::Http::load( $self );
}
}
--- 75,85 ----
# Fetch the content from either the filesystem or database, depending.
! sub fetch_content {
my ( $self ) = @_;
! my $storage_class = $STORAGE_CLASS{ $self->{storage} };
! unless ( $storage_class ) {
! return "Cannot retrieve content -- no storage type specified";
}
+ return $self->{content} = $storage_class->load( $self );
}
***************
*** 109,115 ****
my ( $self, $p ) = @_;
return 1 unless ( $self->{content} );
! return ( $self->{is_file} eq 'yes' )
! ? OpenInteract::Page::File::save( $self, $self->{content} )
! : OpenInteract::Page::Database::save( $self, $self->{content} );
}
--- 111,116 ----
my ( $self, $p ) = @_;
return 1 unless ( $self->{content} );
! my $storage_class = $STORAGE_CLASS{ $self->{storage} };
! return $self->{content} = $storage_class->save( $self );
}
***************
*** 117,123 ****
sub remove_content {
my ( $self, $p ) = @_;
! return ( $self->{is_file} eq 'yes' )
! ? OpenInteract::Page::File::remove( $self )
! : OpenInteract::Page::Database::remove( $self );
}
--- 118,123 ----
sub remove_content {
my ( $self, $p ) = @_;
! my $storage_class = $STORAGE_CLASS{ $self->{storage} };
! return $self->{content} = $storage_class->remove( $self );
}
***************
*** 169,173 ****
directory.
! B<content()>
Retrieve content for this page. Note that we do not make this a
--- 169,173 ----
directory.
! B<fetch_content()>
Retrieve content for this page. Note that we do not make this a
***************
*** 182,186 ****
to simply be the location of the basic page.
! =head1 RULESETS
B<pre_save_action>
--- 182,186 ----
to simply be the location of the basic page.
! =head1 RULES
B<pre_save_action>
|