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