20 |
|
|
21 |
=cut |
=cut |
22 |
|
|
23 |
|
use Moose::Util::TypeConstraints; |
24 |
|
|
25 |
|
enum 'Runnable' => qw/data markup sponge/; |
26 |
|
|
27 |
sub runnable { qw/data markup sponge/ } |
sub runnable { qw/data markup sponge/ } |
28 |
|
|
29 |
has 'class' => ( |
has 'class' => ( |
38 |
default => sub { {} }, |
default => sub { {} }, |
39 |
); |
); |
40 |
|
|
41 |
|
has 'run' => ( |
42 |
|
is => 'rw', |
43 |
|
isa => 'Runnable', |
44 |
|
); |
45 |
|
|
46 |
sub html { |
sub html { |
47 |
my ( $self ) = @_; |
my ( $self ) = @_; |
48 |
|
|
88 |
qq|<option value="$v">$v</option>| |
qq|<option value="$v">$v</option>| |
89 |
} @$values |
} @$values |
90 |
) . qq|</select>|; |
) . qq|</select>|; |
91 |
} else { |
} elsif ( $attr->has_type_constraint && $attr->type_constraint->can('values') ) { |
92 |
$value = $attr->default( $name ) if $attr->has_default; |
$value_html = qq|<select name="$name">| . join("\n", |
93 |
|
map { qq|<option value="$_">$_</option>| } @{ $attr->type_constraint->values } |
94 |
|
) . qq|</select>|; |
95 |
|
} elsif ( $attr->has_default ) { |
96 |
|
$value = $attr->default( $name ); |
97 |
} |
} |
98 |
$value_html = qq|<input type="$type" name="$name" value="$value">| unless $value_html; |
$value_html = qq|<input type="$type" name="$name" value="$value">| unless $value_html; |
99 |
|
|