r23066@martha (orig r906): edenc | 2008-10-05 07:29:59 -0400
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Action / Link.pm
CommitLineData
c8fbb8ad 1package Reaction::UI::ViewPort::Action::Link;
b8faba69 2
3use Reaction::Class;
4
81393881 5use namespace::clean -except => [ qw(meta) ];
6extends 'Reaction::UI::ViewPort';
b8faba69 7
b8faba69 8
b8faba69 9
81393881 10has label => (is => 'rw', required => 1);
11has uri => ( is => 'rw', lazy_build => 1);
b8faba69 12
81393881 13has target => (isa => 'Object', is => 'rw', required => 1);
14has action => (isa => 'CodeRef', is => 'rw', required => 1);
15sub BUILD {
16 my $self = shift;
17 $self->label( $self->label->($self->target) ) if ref $self->label eq 'CODE';
18};
19sub _build_uri {
20 my $self = shift;
21 my $c = $self->ctx;
22 my ($c_name, $a_name, @rest) = @{ $self->action->($self->target, $c) };
23 $c->uri_for($c->controller($c_name)->action_for($a_name),@rest);
b8faba69 24};
25
81393881 26__PACKAGE__->meta->make_immutable;
27
28
b8faba69 291;