--- trunk/lib/Frey/Pipe.pm 2008/11/18 17:11:08 420 +++ trunk/lib/Frey/Pipe.pm 2008/11/19 19:28:09 467 @@ -1,6 +1,6 @@ package Frey::Pipe; use Moose; -extends 'Frey'; +extends 'Frey::ClassLoader'; with 'Frey::Web'; use Frey::Action; @@ -11,25 +11,25 @@ =head1 EXAMPLE - Frey::Feed/data + uri=http://blog.rot13.org/index.xml | Frey::Dumper/markup + Frey::Feed/as_data + uri=http://blog.rot13.org/index.xml | Frey::View::Dumper/as_markup this will produce following code: - Frey::Dumper->new( data => - Frey::Feed->new( uri => 'http://blog.rot13.org/index.xml' )->data - )->markup + Frey::View::Dumper->new( data => + Frey::Feed->new( uri => 'http://blog.rot13.org/index.xml' )->as_data + )->as_markup =cut has pipe => ( is => 'rw', required => 1, - default => 'Frey::Feed/data+uri=http://blog.rot13.org/index.xml|Frey::Dumper/markup', + default => 'Frey::Feed/as_data+uri=http://blog.rot13.org/index.xml|Frey::View::Dumper/as_markup', ); use Data::Dump qw/dump/; -sub markup { +sub as_markup { my ($self) = @_; my $out; @@ -57,21 +57,22 @@ my ( $html, $default ) = Frey::Action->new( class => $class, params => $params )->params_form; warn "$class need more params than ",dump( $default ) if $html && $self->debug; # FIXME replace with query - my $code = '$result = ' . $class . '->new' . dump( %$default ) . '->' . $method . '();'; - warn "# pipe $part -> $code" if $self->debug; - my $result; - eval $code; - die $@ if $@; - warn "# result ",ref( $result ); -# $out .= qq{$part} . dump( $result ) . '
'; + warn "# pipe $part" if $self->debug; + my $o = $self->new_frey_class( $class, $default ); + my $result = $o->$method; + warn "# result ",length( $result ), " bytes ", ref($result); + + $self->content_type( $o->content_type ) if $o->can('content_type'); + $out = $result; + $method =~ s{^as_}{}; $pipe = { $method => $result }; } else { die "don't know what to do with '$part' from ",$self->pipe; } } - warn "# pipe ", $self->title, dump( $self->status ); + warn "# pipe ", $self->title; return $out; }