/[Frey]/trunk/lib/Frey/Web/Field.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

Contents of /trunk/lib/Frey/Web/Field.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 97 - (show annotations)
Fri Jul 11 13:11:36 2008 UTC (15 years, 9 months ago) by dpavlin
File size: 688 byte(s)
Frey::Web::Field is now our main class for web fields (with Coro support)
1 package Frey::Web::Field;
2
3 use Moose::Role;
4 use Coro::Generator;
5 use Data::UUID;
6
7 has 'cont' => (is => 'rw');
8 has 'output' => (is => 'rw');
9 has 'input' => (is => 'rw');
10
11 has 'uuid' => (
12 is => 'ro',
13 isa => 'Str',
14 default => sub { Data::UUID->new->create_str }
15 );
16
17 # Given a name generate a unique field ID
18 sub field_name {
19 my ($self, $name) = @_;
20 return $self->uuid . '-' . $name;
21 }
22
23 sub process {
24 my ($self, $input) = @_;
25 $self->input($input);
26 $self->{cont} ||= generator { while(1) { $self->main } };
27 $self->{cont}->();
28 return $self->output;
29 }
30
31 sub next {
32 my ($self, $output) = @_;
33 $self->output($output);
34 yield();
35 return $self->input;
36 }
37
38 1;
39

  ViewVC Help
Powered by ViewVC 1.1.26