work in progress, listview still broken
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Action / Link.pm
CommitLineData
c8fbb8ad 1package Reaction::UI::ViewPort::Action::Link;
b8faba69 2
3use Reaction::Class;
4
ddccc6a2 5class Link is 'Reaction::UI::ViewPort', which {
b8faba69 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
89939ff9 18 implements _build_uri => as{
b8faba69 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
271;