view Lib/Configuration.pm @ 134:44977efed303

Significant performance optimizations Fixed recursion problems due converting objects to JSON Added cache support for the templates Added discovery feature for the web methods
author wizard
date Mon, 21 Jun 2010 02:39:53 +0400
parents 16ada169ca75
children
line wrap: on
line source

package Configuration;
use strict;

my $Configured = 0;

sub import {
    my ($class,$site) = @_;
    
    if ($site and $site ne $Configured) {
        Configure($site);
        $Configured = $site;
    } elsif (not $site and not $Configured) {
        $Configured = 1;
        require Configuration::Global;
    }
}

our %virtualSite;

sub Configure {
    my $siteName = shift;
    require Configuration::Global;
    
    while ( my ($pattern,$configSite) = each %virtualSite) {
        next if not $siteName =~ $pattern;
        if (ref $configSite eq 'CODE') {
            $configSite->();
        } elsif (not ref $configSite and $configSite) {
            require $configSite;
        }
        last;
    }
}



1;