[MKDoc-commit] [Petal] Allow passing arguments to coderefs (see petal list 23 Mar 2006)

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Fri Jun 16 15:03:05 BST 2006


Log Message:
-----------
[Petal] Allow passing arguments to coderefs (see petal list 23 Mar 2006)

Modified Files:
--------------
    Petal:
        Changes
    Petal/lib/Petal/Hash:
        Var.pm

-------------- next part --------------
Index: Changes
===================================================================
RCS file: /var/spool/cvs/Petal/Changes,v
retrieving revision 1.149
retrieving revision 1.150
diff -LChanges -LChanges -u -r1.149 -r1.150
--- Changes
+++ Changes
@@ -6,6 +6,7 @@
     - pod typos (sarabob)
     - CACHE_ONLY option (Jonathan Vanasco)
     - Add Digest::MD5 dependency (aaron)
+    - Allow passing arguments to coderefs
 
 2.18 Tue Jan 17 13:01:00 2006
     - $Petal::CodeGenerator::PI_RE should be applied newline insensitively
Index: Var.pm
===================================================================
RCS file: /var/spool/cvs/Petal/lib/Petal/Hash/Var.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -Llib/Petal/Hash/Var.pm -Llib/Petal/Hash/Var.pm -u -r1.17 -r1.18
--- lib/Petal/Hash/Var.pm
+++ lib/Petal/Hash/Var.pm
@@ -96,8 +96,11 @@
 	elsif (isa ($current, 'HASH'))
 	{
 	  ACCESS_HASH:
+          unless (isa $current->{$next}, 'CODE')
+          {
 	    confess "Cannot access hash at '$current_path' with parameters (near $argument)"
 	        if ($has_args and not $has_path_tokens);
+          }
 	    $current = $current->{$next};
 	}
 	elsif (isa ($current, 'ARRAY'))
@@ -127,7 +130,7 @@
 	    return '';
 	}
 
-	$current = (isa ($current, 'CODE')) ? $current->() : $current;
+	$current = (isa ($current, 'CODE')) ? $current->(@args) : $current;
 	$current_path .= "/$next";
     }
     


More information about the MKDoc-commit mailing list