--- trunk/lib/Frey/Run.pm 2008/11/05 08:20:57 285 +++ trunk/lib/Frey/Run.pm 2008/11/08 23:34:43 339 @@ -1,10 +1,14 @@ package Frey::Run; use Moose; -extends 'Frey'; +#extends 'Frey::ClassLoader'; +extends 'Frey::PPI'; with 'Frey::Web'; with 'Frey::Config'; with 'Frey::Escape'; +use Data::Dump qw/dump/; +use Frey::Dumper; + =head1 NAME Frey::Run - display required form field for Class and run it @@ -12,11 +16,11 @@ =head1 DESCRIPTION This object will try to run other Moose objects from your application. It -will try to invoke C, C or C method on the. +will try to invoke C, and C method on the. =cut -sub execute { qw/data markup/ } +sub runnable { qw/data markup sponge/ } has 'class' => ( is => 'rw', @@ -30,13 +34,13 @@ default => sub { {} }, ); -use Data::Dump qw/dump/; - sub html { my ( $self ) = @_; my $class = $self->class; + $self->load_class( $class ); + my @required = grep { defined $_ && $_->can('name') && !defined( $self->params->{ $_->name } ) @@ -50,12 +54,19 @@ my $html; my $values = {}; - my $values = $self->config($class) if $self->can('config'); + $values = $self->config($class); + warn "# $class config = ",dump( $values ); if ( @required ) { - $html = qq|

Required params for $class

|; - foreach my $attr ( @required ) { - my $name = $attr->name; + $html = qq|

$class params

|; + + my $a; + my @attrs = map { $a->{$_}++; $_ } $self->attribute_order; + push @attrs, $_ foreach grep { ! $a->{$_} } map { $_->name } @required; + warn "# attrs = ",dump( @attrs ); + + foreach my $name ( @attrs ) { + my $attr = $class->meta->get_attribute( $name ); my $type = $name =~ m/^pass/ ? 'password' : 'text'; my $value = $values ? $values->{$name} : @@ -76,8 +87,16 @@ $html .= qq{$@}; } warn ">>> markup $class ",length( $html ), " bytes\n"; + } elsif ( $o->can('sponge') ) { + my $data = $o->sponge; + $html .= ''; + $html .= ''; + $html .= '' foreach @{ $data->{rows} }; + $html .= '
' . join('', @{$data->{NAME}} ) . '
' . join('', @$_ ) . '
'; } elsif ( $o->can('data') ) { - $html = '' . $self->html_escape( dump( $o->data ) ) . ''; + my $data = $o->data; + $html .= Frey::Dumper->new( data => $data )->markup; + $html .= '
' . $self->html_dump( $data ) . ''; } else { $html = "IGNORE: $class ", $o->dump; warn $html;