/[Frey]/trunk/lib/Frey/Run.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Run.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 204 by dpavlin, Thu Oct 30 22:20:02 2008 UTC revision 222 by dpavlin, Fri Oct 31 23:17:56 2008 UTC
# Line 2  package Frey::Run; Line 2  package Frey::Run;
2  use Moose;  use Moose;
3  extends 'Frey';  extends 'Frey';
4  with 'Frey::Web';  with 'Frey::Web';
5    with 'Frey::Config';
6    
7  =head1 NAME  =head1 NAME
8    
9  Frey::Run - display required form field for Class and run it  Frey::Run - display required form field for Class and run it
10    
11    =head1 DESCRIPTION
12    
13    This object will try to run other Moose objects from your application. It
14    will try to invoke C<html> or C<markup> method on the.
15    
16  =cut  =cut
17    
18  has 'class' => (  has 'class' => (
# Line 17  has 'class' => ( Line 23  has 'class' => (
23    
24  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
25    
26  sub html {  sub request {
27          my ( $self, $req ) = @_;          my ( $self, $req ) = @_;
28    
29          my %params = $req->params;          my %params = $req->params;
# Line 39  sub html { Line 45  sub html {
45    
46          if ( @required ) {          if ( @required ) {
47                  $html = qq|<h1>Required params for $class</h1><form method="post">|;                  $html = qq|<h1>Required params for $class</h1><form method="post">|;
48                  $html .= qq|<label for="$_">$_</label><input type="text" name="$_">| foreach @required;                  foreach my $name ( @required ) {
49                            my $type = $name =~ m/^pass/ ? 'password' : 'text';
50                            my $value = $self->config($class)->{$name};
51                            $html .= qq|<label for="$name">$name</label><input type="$type" name="$name" value="$value">|;
52                    }
53                  $html .= qq|<input type="submit" value="Run $class"></form>|;                  $html .= qq|<input type="submit" value="Run $class"></form>|;
54          } else {          } else {
55                  my $o = $class->new( %params );                  my $o = $class->new( %params );
56                  $o->depends if $o->can('depends');                  $o->depends if $o->can('depends');
57                  if ( $o->can('html') ) {                  if ( $o->can('request') ) {
58                          warn "## turning over to $o->html";                          warn "## turning over to $o->request";
59                          $o->html( $req );                          $o->request( $req );
60                  } elsif ( $o->can('markup') ) {                  } elsif ( $o->can('markup') ) {
61                          warn "## using $o->markup";                          warn "## using $o->markup";
62                          $html = $o->markup;                          $html = $o->markup;

Legend:
Removed from v.204  
changed lines
  Added in v.222

  ViewVC Help
Powered by ViewVC 1.1.26