BingoX

 view release on metacpan or  search on metacpan

lib/BingoX/Argon.pm  view on Meta::CPAN


BEGIN {
	$BingoX::Argon::REVISION	= (qw$Revision: 2.9 $)[-1];
	$BingoX::Argon::VERSION		= '1.92';
	
	$debug	= undef;

	if ($debug) {
		eval 'use Data::Dumper';
	}
}

=item C<new> ( [ \%data ] )

Creates a new Application object.

=cut
sub new {
	my $self	= shift;
	my $class	= ref($self) || $self;
	## backward compatibility: $r was traditionally the first arg passed. ##
	my $r		= (ref($_[0]) eq 'HASH') ? $class->r : shift;
	## Next comes the (optional) data ##
	my $data	= shift || { };
	$data->{'_r'} ||= $r;
	bless $data, $class;
} # END of new


=back

=head2 OBJECT METHODS

=over 4

=item C<r> (  )

returns the Display object's Apache request object. Or if for some 
reason the object doesn't have one, it creates a new one.

=cut
sub r { ref($_[0]) ? $_[0]->{'_r'} ||= Apache->request : Apache->request }


=item C<available_display_classes> (  )

Static method returns the subclass's \%display_classes.

=cut
sub display_classes {
	my $self	= shift;
	my $class	= ref($self) || $self;
	no strict 'refs';
	(defined %{"${class}::display_classes"}) ? \%{"${class}::display_classes"} : { };
} # END of display_classes


=item C<data_class> (  )

Static method returns data class defined for application subclass.  
If none is assigned, guess. :-)

=cut
sub data_class {
	my $self	= shift;
	my $class	= ref($self) || $self;
	no strict 'refs';
	${"${class}::data_class"} || $class . '::Data';
} # END of data_class


=item C<dbh> (  )

Caches and returns a reference to the app's Data Class dbh.

=cut
sub dbh {
	my $self	= shift;
	my $class	= ref($self) || return undef;
	return $self->{'_dbh'} if (ref $self->{'_dbh'});
	$self->{'_dbh'} = $self->data_class->dbh if ($self->data_class->can('dbh'));
	warn "No data classes found for $class" unless (ref $self->{'_dbh'});
	return $self->{'_dbh'};
} # END of dbh


=item C<cgi> (  )

Returns the current CGI object or creates a new one.

=cut
sub cgi { ref($_[0]) ? $_[0]->{'_cgi'} ||= CGI->new : CGI->new }


=item C<conf> (  )

Caches and returns a Conf object.
Overload this if you want to use a static Conf module.

=cut
sub conf {
	ref($_[0])
	?
	$_[0]->{'_conf'} ||= Conf->new( $_[0]->r->dir_config('conf') )
	:
	Conf->new( $_[0]->r->dir_config('conf') )
} # END of conf


=item C<query_url> ( )

Returns the path of the user's location.

=cut
sub query_url {
	return $_[0]->cgi->url( -ABSOLUTE => 1);
} # END of query_url


=item C<param> ( $name )



( run in 1.202 second using v1.01-cache-2.11-cpan-5b529ec07f3 )