NAME
C - Context
SYNOPSIS
use C;
C::app $app;
my $conf = C::load 'example.conf';
my $app = C::app;
my $db = C::db;
my $cfg = C::config;
my $ctx = C::C;
DESCRIPTION
C is a small collection of global accessors. It keeps references to the current application object and, optionally, a request context object.
FUNCTIONS
C
my $ctx = C::C;
Return the current context stored in $C if it is set and still has transaction tx. Otherwise returns undef.
app
C::app $app;
my $app = C::app;
Set or get the application object.
debug
my $bool = C::debug;
True if $ENV{DEBUG} is set or the application is in development mode.
db
my $db = C::db;
Quick access to your DB handle. Shortcut for C::app->db.
config
my $cfg = C::config;
Return configuration. If an application object is set, this returns C::app->config. Otherwise it returns the last configuration loaded by "load".
load
my $cfg = C::load 'example.conf';
Evaluate a Perl config file with do and store the returned value (usually a hash reference). Dies on errors.
Configuration example:
+{
SectionOne => ... # Any regular perl data structure goes here
DbAccess => {
HOST => '127.0.0.1',
PORT => 5432,
ROOT => 'Htr0-ChangeThis',
PASS => 'WscH-ChangeThis',
},
};