--- trunk/lib/Frey/Run.pm 2008/11/19 15:28:23 455
+++ trunk/lib/Frey/Run.pm 2008/11/25 14:15:34 517
@@ -7,7 +7,7 @@
with 'Frey::Session';
use Data::Dump qw/dump/;
-use Frey::Dumper;
+use Frey::View::Dumper;
use JSON;
use YAML;
@@ -78,22 +78,20 @@
if ( $is_role ) {
$o = $instance;
} else {
- $o = $class->new( %{ $self->params } );
+ $o = $self->new_frey_class( $class, $self->params );
}
$o->depends if $o->can('depends');
- push @{ $self->status }, { qq|$class| => $self->params };
+ my @status;
- if ( $self->run eq 'markup' ) {
+ push @status, { $self->editor( $class ) => $self->params } if $o->can('status');
+
+ if ( $self->run eq 'as_markup' && ! $o->can('page') ) {
warn "## using ",ref($o), "->as_markup";
- if ( $o->can('page') ) {
- $html = $o->page;
- }
$body = $o->as_markup unless $html;
-
- warn ">>> markup $class ",length( $html || $body ), " ", $html ? 'html' : 'body', " bytes";
- } elsif ( $self->run eq 'sponge' ) {
+ warn ">>> markup $class ",length( $body ), " ", $html ? 'html' : 'body', " bytes";
+ } elsif ( $self->run eq 'as_sponge' ) {
$data = $o->as_sponge;
confess "invalid data from sponge = ", dump( $data ) unless ref($data) eq 'HASH';
if ( $self->format eq 'html' ) {
@@ -105,7 +103,7 @@
$body .= '
' . join(' | ', @$_ ) . ' |
' foreach @{ $data->{rows} };
$body .= '';
}
- } elsif ( $self->run eq 'data' ) {
+ } elsif ( $self->run eq 'as_data' ) {
$data = $o->as_data;
} else {
$body = $self->error( "IGNORE: $class ", $o->dump );
@@ -114,22 +112,27 @@
if ( defined $data ) {
$html .= to_json( $data ) if $self->format =~ m{js(on)?};
$html .= Dump( $data ) if $self->format =~ m{ya?ml};
- push @{ $self->status }, { 'data' => $data };
+ push @status, { 'data' => $data };
}
if ( ! $html ) {
- $body .= Frey::Dumper->new( data => $data )->as_markup;
+ $body = Frey::View::Dumper->new( data => $body )->as_markup if ref $body;
+ $body .= Frey::View::Dumper->new( data => $data )->as_markup if defined $data;
}
- # override our status with one from object
- eval {
- $self->status( $o->status );
- };
- warn "can't override status: $@" if $@;
- };
+ warn "# status ",dump(@status);
+ if ( $self->run eq 'as_markup' && $o->can('page') ) {
+ $o->add_status($_) foreach @status;
+ $html = $o->page;
+ warn "got ", length($html), "for page";
+ } else {
+ $self->add_status($_) foreach @status;
+ }
+ };
if ( ref($body) eq 'HASH' ) {
$html = $self->page( %$body );
+ warn "WARNING: old calling method which is depriciated";
} elsif ( $body && ! $html ) {
$html = $self->page( title => $self->class . ' run', body => $body );
};