1 |
package Frey::Run; |
package Frey::Run; |
2 |
use Moose; |
use Moose; |
3 |
extends 'Frey'; |
extends 'Frey::ClassLoader'; |
4 |
with 'Frey::Web'; |
with 'Frey::Web'; |
5 |
with 'Frey::Config'; |
with 'Frey::Config'; |
6 |
with 'Frey::Escape'; |
with 'Frey::Escape'; |
7 |
|
|
8 |
|
use Data::Dump qw/dump/; |
9 |
|
use Frey::Dumper; |
10 |
|
|
11 |
=head1 NAME |
=head1 NAME |
12 |
|
|
13 |
Frey::Run - display required form field for Class and run it |
Frey::Run - display required form field for Class and run it |
15 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
16 |
|
|
17 |
This object will try to run other Moose objects from your application. It |
This object will try to run other Moose objects from your application. It |
18 |
will try to invoke C<data>, C<html> or C<markup> method on the. |
will try to invoke C<data>, and C<markup> method on the. |
19 |
|
|
20 |
=cut |
=cut |
21 |
|
|
22 |
sub execute { qw/data markup/ } |
sub runnable { qw/data markup/ } |
23 |
|
|
24 |
has 'class' => ( |
has 'class' => ( |
25 |
is => 'rw', |
is => 'rw', |
33 |
default => sub { {} }, |
default => sub { {} }, |
34 |
); |
); |
35 |
|
|
|
use Data::Dump qw/dump/; |
|
|
|
|
36 |
sub html { |
sub html { |
37 |
my ( $self ) = @_; |
my ( $self ) = @_; |
38 |
|
|
39 |
my $class = $self->class; |
my $class = $self->class; |
40 |
|
|
41 |
|
$self->load_class( $class ); |
42 |
|
|
43 |
my @required = |
my @required = |
44 |
grep { |
grep { |
45 |
defined $_ && $_->can('name') && !defined( $self->params->{ $_->name } ) |
defined $_ && $_->can('name') && !defined( $self->params->{ $_->name } ) |
53 |
|
|
54 |
my $html; |
my $html; |
55 |
my $values = {}; |
my $values = {}; |
56 |
my $values = $self->config($class) if $self->can('config'); |
$values = $self->config($class); |
57 |
|
warn "# $class config = ",dump( $values ); |
58 |
|
|
59 |
if ( @required ) { |
if ( @required ) { |
60 |
$html = qq|<h1>Required params for $class</h1><form method="post">|; |
$html = qq|<h1>Required params for $class</h1><form method="post">|; |
81 |
} |
} |
82 |
warn ">>> markup $class ",length( $html ), " bytes\n"; |
warn ">>> markup $class ",length( $html ), " bytes\n"; |
83 |
} elsif ( $o->can('data') ) { |
} elsif ( $o->can('data') ) { |
84 |
$html = '<code>' . $self->html_escape( dump( $o->data ) ) . '</code>'; |
my $data = $o->data; |
85 |
|
$html .= Frey::Dumper->new( data => $data )->markup; |
86 |
|
$html .= '<hr/><code>' . $self->html_dump( $data ) . '</code>'; |
87 |
} else { |
} else { |
88 |
$html = "IGNORE: $class ", $o->dump; |
$html = "IGNORE: $class ", $o->dump; |
89 |
warn $html; |
warn $html; |