diff options
Diffstat (limited to 'lib/Reaction/UI/ViewPort/Action/Link.pm')
-rw-r--r-- | lib/Reaction/UI/ViewPort/Action/Link.pm | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/Reaction/UI/ViewPort/Action/Link.pm b/lib/Reaction/UI/ViewPort/Action/Link.pm index c364fd7..824c33d 100644 --- a/lib/Reaction/UI/ViewPort/Action/Link.pm +++ b/lib/Reaction/UI/ViewPort/Action/Link.pm @@ -2,26 +2,28 @@ package Reaction::UI::ViewPort::Action::Link; use Reaction::Class; -class Link is 'Reaction::UI::ViewPort', which { +use namespace::clean -except => [ qw(meta) ]; +extends 'Reaction::UI::ViewPort'; - has label => (is => 'rw', required => 1); - has uri => ( is => 'rw', lazy_build => 1); - has target => (isa => 'Object', is => 'rw', required => 1); - has action => (isa => 'CodeRef', is => 'rw', required => 1); - implements BUILD => as { - my $self = shift; - $self->label( $self->label->($self->target) ) if ref $self->label eq 'CODE'; - }; - - implements _build_uri => as{ - my $self = shift; - my $c = $self->ctx; - my ($c_name, $a_name, @rest) = @{ $self->action->($self->target, $c) }; - $c->uri_for($c->controller($c_name)->action_for($a_name),@rest); - }; +has label => (is => 'rw', required => 1); +has uri => ( is => 'rw', lazy_build => 1); +has target => (isa => 'Object', is => 'rw', required => 1); +has action => (isa => 'CodeRef', is => 'rw', required => 1); +sub BUILD { + my $self = shift; + $self->label( $self->label->($self->target) ) if ref $self->label eq 'CODE'; +}; +sub _build_uri { + my $self = shift; + my $c = $self->ctx; + my ($c_name, $a_name, @rest) = @{ $self->action->($self->target, $c) }; + $c->uri_for($c->controller($c_name)->action_for($a_name),@rest); }; +__PACKAGE__->meta->make_immutable; + + 1; |