Apache2-WebApp-Toolkit

 view release on metacpan or  search on metacpan

lib/Apache2/WebApp/AppConfig.pm  view on Meta::CPAN


#~~~~~~~~~~~~~~~~~~~~~~~~~~[  OBJECT METHODS  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#----------------------------------------------------------------------------+
# parse($file)
#
# Return the configuration name/value pairs as a reference to a hash.

sub parse {
    my ($self, $file)
      = validate_pos(@_,
          { type => OBJECT },
          { type => SCALAR }
      );

    my $config;

    eval {
        $config = AppConfig->new(
            {
                CREATE => 1,

lib/Apache2/WebApp/Base.pm  view on Meta::CPAN

    return ${"${class}::VERSION"};
}

#----------------------------------------------------------------------------+
# error($mesg)
#
# Output errors/exceptions and exit.

sub error {
    my ($self, $mesg)
      = validate_pos(@_,
          { type => OBJECT },
          { type => SCALAR, optional => 1 }
      );

    my $class = ref $self || $self;
    $mesg ||= 'Failed to initialize object';
    my $error = "[$class] $mesg";

    if ( $self->{DEBUG} ) { confess $error } else { die $error }
}

lib/Apache2/WebApp/Helper.pm  view on Meta::CPAN

    }, $class);
}

#----------------------------------------------------------------------------+
# set_vars(\%vars)
#
# Set the template object attributes.

sub set_vars {
    my ($self, $vars)
      = validate_pos(@_,
          { type => OBJECT  },
          { type => HASHREF }
      );

    @{ $self->{VARS} }{keys %$vars} = values %$vars;
}

#----------------------------------------------------------------------------+
# write_file( $file, $output )
#
# Write the template output to a file.

sub write_file {
    my ($self, $file, $output)
      = validate_pos(@_,
          { type => OBJECT },
          { type => SCALAR },
          { type => SCALAR }
      );

    $self->{TEMPLATE}->process($file, $self->{VARS}, $output)
      or $self->error(
          "@{[ $self->{TEMPLATE}->error() ]} at $file"
        );

    print "created file $output\n" if ( $self->{VERBOSE} );
}

#----------------------------------------------------------------------------+
# get_source_path()
#
# Returns the path to the /webapp-toolkit source directory.

sub get_source_path {
    my $self
      = validate_pos(@_,
          { type => OBJECT }
      );

    my ($package, $filename, $line) = caller;
    $filename =~ s/^(.*)\/lib\/.*$/$1/;
    return $filename . '/share/webapp-toolkit';
}

#----------------------------------------------------------------------------+
# error($mesg)
#
# Print errors/exceptions to STDOUT and exit.

sub error {
    my ($self, $mesg)
      = validate_pos(@_,
          { type => OBJECT },
          { type => SCALAR }
      );

    print "$mesg\n";
    exit;
}

#----------------------------------------------------------------------------+
# AUTOLOAD()

lib/Apache2/WebApp/Plugin.pm  view on Meta::CPAN


#~~~~~~~~~~~~~~~~~~~~~~~~~~[  OBJECT METHODS  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#----------------------------------------------------------------------------+
# load($name)
#
# Include the class (plugin('class')) if it hasn't already been included.

sub load {
    my ($self, $name)
      = validate_pos(@_,
          { type => OBJECT },
          { type => SCALAR }
      );

    $name =~ s/\b(\w)/\u$1/g;

    my $package = "Apache2::WebApp::Plugin::$name";

    unless ( $package->can('isa') ) {
        eval "require $package";

lib/Apache2/WebApp/Stash.pm  view on Meta::CPAN


#~~~~~~~~~~~~~~~~~~~~~~~~~~[  OBJECT METHODS  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#----------------------------------------------------------------------------+
# set($name, \%vars)
#
# Set the object attribute.  Return a reference to this object.

sub set {
    my ($self, $name, $vars)
      = validate_pos(@_,
          { type => OBJECT },
          { type => SCALAR },
          { type => ARRAYREF | HASHREF | SCALAR | UNDEF }
      );

    $self->{ uc($name) } = $vars;
    return $self->{ uc($name) };
}

#----------------------------------------------------------------------------+
# get($name)
#
# Get the object attribute.  Return a reference to this object.

sub get {
    my ($self, $name)
      = validate_pos(@_,
          { type => OBJECT },
          { type => SCALAR }
      );

    return $self->{ uc($name) };
}

#----------------------------------------------------------------------------+
# AUTOLOAD()
#



( run in 0.256 second using v1.01-cache-2.11-cpan-4d50c553e7e )