package MKDoc::Handler::Cache::Capture;
use base qw /Apache::RegistryNG Apache/;


sub new
{
    my ($class, $r) = @_;
    tie *STDOUT, $class, $r;
    return tied *STDOUT;
}


sub print
{
    my $self = shift;
    $self->{_data} ||= '';
    $self->{_data} .= join ('', @_);
}


sub data
{
    my $self = shift;
    return $self->{_data}; 
}


sub TIEHANDLE
{
    my ($class, $r) = @_;
    return bless { r => $r, _r => $r, _data => undef }, $class;
}


sub PRINT
{
    shift->print (@_);
}


1;


package MKDoc::Handler::Cache;
use base qw /Apache::RegistryNG/;
use IO::Capture::Stdout;
use Data::Dumper;
use strict;
use warnings;
use Apache;
use Apache::Constants;

sub handler ($$)
{
    my ($class, $r) = (@_ >= 2) ? (shift, shift) : (__PACKAGE__, shift);
    $r->log_error ('We are in MKDoc::Handler::Cache');
    $r->log_error ($r->filename());

    my $fake_r = MKDoc::Handler::Cache::Capture->new ($r);
    my $ret    = $class->SUPER::handler ($fake_r);

    open FP, ">/tmp/foo.txt";
    print FP $fake_r->data();
    close FP;

    return DECLINED; 
}


1;

__END__

