dwim selects and bugfixes, new transform_attribute method and handled trailing '...
[catagits/HTML-Zoom.git] / lib / HTML / Zoom / StreamBase.pm
index 6c0b416..8fa8d53 100644 (file)
@@ -1,7 +1,6 @@
 package HTML::Zoom::StreamBase;
 
-use strict;
-use warnings FATAL => 'all';
+use strictures 1;
 use HTML::Zoom::TransformBuilder;
 
 sub _zconfig { shift->{_zconfig} }
@@ -83,9 +82,27 @@ 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);
 }
 
+sub AUTOLOAD {
+  my ($self, $selector, @args) = @_;
+  my $meth = our $AUTOLOAD;
+  $meth =~ s/.*:://;
+  return $self = $self->select($selector)->$meth(@args);
+}
+
 1;