package Reaction::Types::File;
-use MooseX::Types
- -declare => [qw/File Upload/];
+use MooseX::Types -declare => [qw/File Upload/];
use MooseX::Types::Moose 'Object';
-use Catalyst::Request::Upload;
-
-subtype File
- => as Object
- => where { $_->isa('Path::Class::File') }
- => message { "Must be a file" };
-
-subtype Upload
- => as Object
- => where { $_->isa('Catalyst::Request::Upload') }
- => message { "Must be a file" };
-
-coerce File
- => from Upload
- => via { Path::Class::File->new($_->tempname) };
-
+use Path::Class::File;
+
+subtype File, as Object, where { $_->isa('Path::Class::File') },
+ message { "Must be a file" };
+
+subtype Upload, as Object, where { $_->isa('Catalyst::Request::Upload') },
+ message { "Must be a file" };
+
+coerce File, from Upload, via { Path::Class::File->new( $_->tempname ) };
+
1;
=head1 NAME
class File is 'Reaction::UI::ViewPort::Field', which {
- has '+value' => (isa => 'File');
+ has '+value' => (isa => Reaction::Types::File::File());
has uri => ( is => 'rw', lazy_build => 1);
package Reaction::UI::ViewPort::Field::Mutable::File;
+use Reaction::Types::File qw/Upload/;
use Reaction::Class;
-use Reaction::Types::File;
class File is 'Reaction::UI::ViewPort::Field', which {
- does 'Reaction::UI::ViewPort::Field::Role::Mutable';
+ does 'Reaction::UI::ViewPort::Field::Role::Mutable::Simple';
- has '+value' => (isa => 'Upload');
+ has '+value' => (isa => Upload);
override apply_our_events => sub {
my ($self, $ctx, $events) = @_;
- my $value_key = join(':', $self->location, 'value');
+ my $value_key = $self->event_id_for('value_string');
if (my $upload = $ctx->req->upload($value_key)) {
local $events->{$value_key} = $upload;
return super();
}
};
+ implements adopt_value_string => sub {
+ my($self) = @_;
+ $self->value($self->value_string) if $self->value_string;
+ };
+
+ overrides _value_string_from_value => sub { '' };
+
};
1;