projects
/
catagits/HTML-Zoom.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
Added apply_if to only run an apply block if a predicate is true
[catagits/HTML-Zoom.git]
/
lib
/
HTML
/
Zoom
/
StreamBase.pm
diff --git
a/lib/HTML/Zoom/StreamBase.pm
b/lib/HTML/Zoom/StreamBase.pm
index
6c0b416
..
e063c48
100644
(file)
--- a/
lib/HTML/Zoom/StreamBase.pm
+++ b/
lib/HTML/Zoom/StreamBase.pm
@@
-83,6
+83,17
@@
sub apply {
$self->$code;
}
+sub apply_if {
+ my ($self, $predicate, $code) = @_;
+ if($predicate) {
+ local $_ = $self;
+ $self->$code;
+ }
+ else {
+ $self;
+ }
+}
+
sub to_html {
my ($self) = @_;
$self->_zconfig->producer->html_from_stream($self);