work in progress, listview still broken
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Action / Link.pm
1 package Reaction::UI::ViewPort::Action::Link;
2
3 use Reaction::Class;
4
5 class Link is 'Reaction::UI::ViewPort', which {
6
7   has label  => (is => 'rw',  required => 1);
8   has uri    => ( is => 'rw', lazy_build => 1);
9
10   has target => (isa => 'Object',  is => 'rw', required   => 1);
11   has action => (isa => 'CodeRef', is => 'rw', required   => 1);
12
13   implements BUILD => as{
14     my $self = shift;
15     $self->label( $self->label->($self->target) ) if ref $self->label eq 'CODE';
16   };
17
18   implements _build_uri => as{
19     my $self = shift;
20     my $c = $self->ctx;
21     my ($c_name, $a_name, @rest) = @{ $self->action->($self->target, $c) };
22     $c->uri_for($c->controller($c_name)->action_for($a_name),@rest);
23   };
24
25 };
26
27 1;