[Templates-cvs] cvs commit: TT3/lib/Template VObject.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
Mon, 29 Mar 2004 14:48:30 +0100
cvs 04/03/29 13:48:29
Added: lib/Template VObject.pm
Log:
* added Template::Object
Revision Changes Path
1.1 TT3/lib/Template/VObject.pm
Index: VObject.pm
===================================================================
#========================================================================
#
# Template::VObject
#
# DESCRIPTION
# Base class virtual object module.
#
# AUTHOR
# Andy Wardley <abw@wardley.org>
#
# COPYRIGHT
# Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
# Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
# Copyright (C) 2004 Fotango Ltd.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# REVISION
# $Id: VObject.pm,v 1.1 2004/03/29 13:48:29 abw Exp $
#
#========================================================================
package Template::VObject;
use strict;
use warnings;
use Template::Base;
use base qw( Template::Base );
use vars qw( $VERSION $DEBUG $ERROR );
$VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/);
$DEBUG = 0 unless defined $DEBUG;
$ERROR = '';
sub methods {
my $class = shift;
no strict 'refs';
return ${"$class\::METHODS"} || { };
}
#------------------------------------------------------------------------
# ref() [% obj.ref %]
#
# Equivalent of Perl's ref() function.
#------------------------------------------------------------------------
sub ref {
return CORE::ref($_[0]);
}
#------------------------------------------------------------------------
# type() [% obj.type %]
#
# Returns a string representing the TT object type, either defined in
# the $TYPE package variable or taken from the last part of the class
# name, e.g 'Hash', 'List', 'Text'.
#------------------------------------------------------------------------
sub type {
my $self = shift;
my $class = CORE::ref $self || $self;
no strict 'refs';
return ${"$class\::TYPE"} || ($class =~ /([^:]+)$/) && $1;
}
1;
__END__
=head1 NAME
Template::VObject - base class virtual object
=head1 SYNOPSIS
# TODO
=head1 DESCRIPTION
TODO
=head1 AUTHOR
Andy Wardley E<lt>abw@wardley.orgE<gt>
=head1 VERSION
$Revision: 1.1 $
=head1 COPYRIGHT
Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
Copyright (C) 2004 Fotango Ltd.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=cut
# Local Variables:
# mode: perl
# perl-indent-level: 4
# indent-tabs-mode: nil
# End:
#
# vim: expandtab shiftwidth=4: