[Templates-cvs] cvs commit: TT3/lib/Template/VObject Hash.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
Mon, 29 Mar 2004 17:33:51 +0100
cvs 04/03/29 16:33:49
Modified: lib/Template/VObject Hash.pm
Log:
* minor fixups
Revision Changes Path
1.2 +22 -22 TT3/lib/Template/VObject/Hash.pm
Index: Hash.pm
===================================================================
RCS file: /template-toolkit/TT3/lib/Template/VObject/Hash.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Hash.pm 2004/03/29 13:50:03 1.1
+++ Hash.pm 2004/03/29 16:33:48 1.2
@@ -18,7 +18,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Hash.pm,v 1.1 2004/03/29 13:50:03 abw Exp $
+# $Id: Hash.pm,v 1.2 2004/03/29 16:33:48 abw Exp $
#
#========================================================================
@@ -30,21 +30,21 @@
use base qw( Template::VObject );
use vars qw( $VERSION $DEBUG $ERROR $THROW $METHODS );
-$VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/);
$DEBUG = 0 unless defined $DEBUG;
$ERROR = '';
$THROW = 'Hash';
$METHODS = {
- # contructor methods
- new => \&new,
- clone => \&clone,
- copy => \©,
-
- # metadata methods
+ # ref/type methods
ref => __PACKAGE__->can('ref'),
type => \&type,
+ # constructor methods
+ new => \&new,
+ clone => \&clone,
+
# converter methods
+ copy => \©,
hash => \&hash,
list => \&list,
text => \&text,
@@ -76,6 +76,16 @@
#------------------------------------------------------------------------
+# type() [% hash.type %]
+#------------------------------------------------------------------------
+
+sub type {
+ return 'Hash';
+}
+
+
+
+#------------------------------------------------------------------------
# new() [% Hash.new(a=10, b=20) %]
#
# Accepts a hash reference which is blessed into a hash object, or
@@ -90,9 +100,9 @@
if (@_ && UNIVERSAL::isa($_[0], $class)) {
# copy Hash object passed as argument
$self = shift;
- $self = $self->copy();
+ $self = $self->copy(@_);
}
- elsif (@_ && UNIVERSAL::isa($_[0], 'HASH')) {
+ elsif (@_ == 1 && UNIVERSAL::isa($_[0], 'HASH')) {
# bless hash array passed as argument
$self = shift;
}
@@ -129,16 +139,6 @@
}
-#------------------------------------------------------------------------
-# type() [% hash.type %]
-#
-# Returns 'Hash'.
-#------------------------------------------------------------------------
-
-sub type {
- return 'Hash';
-}
-
#------------------------------------------------------------------------
# hash() [% hash.hash %]
@@ -169,14 +169,14 @@
#------------------------------------------------------------------------
sub text {
- my ($hash, $joint1, $joint2) = @_;
+ my ($self, $joint1, $joint2) = @_;
$joint1 = ' => ' unless defined $joint1;
$joint2 = ', ' unless defined $joint2;
return join($joint2, map {
- my $val = $hash->{ $_ };
+ my $val = $self->{ $_ };
$val = '' unless defined $val;
"$_$joint1$val";
- } sort keys %$hash);
+ } sort keys %$self);
}
@@ -496,7 +496,7 @@
=head1 VERSION
-$Revision: 1.1 $
+$Revision: 1.2 $
=head1 COPYRIGHT