Intermediate commit - just have to add/fix POD for two classes, then done
[p5sagit/Excel-Template.git] / lib / Excel / Template / Container / Conditional.pm
index cd7ec75..45f9fb7 100644 (file)
@@ -17,7 +17,7 @@ my %isOp = (
     (map { $_ => $_ } ( 'gt', 'lt', 'eq', 'ne', 'ge', 'le' )),
 );
 
-sub conditional_passes
+sub _conditional_passes
 {
     my $self = shift;
     my ($context) = @_;
@@ -37,10 +37,6 @@ sub conditional_passes
             ? $isOp{$op}
             : '==';
 
-        # Force numerical context on both values;
-        $value *= 1;
-        $val *= 1;
-
         my $res;
         for ($op)
         {
@@ -60,22 +56,22 @@ sub conditional_passes
             die "Unknown operator in conditional resolve", $/;
         }
 
-        return 0 unless $res;
+        return $res && 1;
     }
-    elsif (my $is = uc $context->get($self, 'IS'))
+
+    my $istrue = $val && 1;
+
+    my $is = uc $context->get($self, 'IS') || 'TRUE';
+    if ($is eq 'TRUE')
     {
-        my $istrue = $val && 1;
-        if ($is eq 'TRUE')
-        {
-            return 0 unless $istrue;
-        }
-        else
-        {
-            warn "Conditional 'is' value was [$is], defaulting to 'FALSE'" . $/
-                if $is ne 'FALSE';
+        return 0 unless $istrue;
+    }
+    else
+    {
+        warn "Conditional 'is' value was [$is], defaulting to 'FALSE'" . $/
+            if $is ne 'FALSE' && $^W;
 
-            return 0 if $istrue;
-        }
+        return 0 if $istrue;
     }
 
     return 1;
@@ -86,7 +82,7 @@ sub render
     my $self = shift;
     my ($context) = @_;
 
-    return 1 unless $self->conditional_passes($context);
+    return 1 unless $self->_conditional_passes($context);
 
     return $self->iterate_over_children($context);
 }
@@ -96,7 +92,7 @@ sub max_of
     my $self = shift;
     my ($context, $attr) = @_;
 
-    return 0 unless $self->conditional_passes($context);
+    return 0 unless $self->_conditional_passes($context);
 
     return $self->SUPER::max_of($context, $attr);
 }
@@ -106,7 +102,7 @@ sub total_of
     my $self = shift;
     my ($context, $attr) = @_;
 
-    return 0 unless $self->conditional_passes($context);
+    return 0 unless $self->_conditional_passes($context);
 
     return $self->SUPER::total_of($context, $attr);
 }
@@ -155,7 +151,7 @@ string comparison operators. All 6 of each kind is supported.
 If VALUE is not set, then IS is checked. IS is allowed to be either "TRUE" or
 "FALSE". The boolean value of NAME is checked against IS.
 
-=back 4
+=back
 
 =head1 CHILDREN
 
@@ -180,7 +176,7 @@ In the above example, the children will be executed if the value of __ODD__
 
 =head1 AUTHOR
 
-Rob Kinyon (rkinyon@columbus.rr.com)
+Rob Kinyon (rob.kinyon@gmail.com)
 
 =head1 SEE ALSO