aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgroditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2009-10-02 20:10:38 +0000
committergroditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2009-10-02 20:10:38 +0000
commitb8da93ebed6c17a1919d7cde6b784181b5b6d2c8 (patch)
tree8779ed633643b3900d1c2874c52c695fe03e4dc6
parent110f5e491eb25e6434bd964388fdbba9619b35f6 (diff)
downloadreaction-b8da93ebed6c17a1919d7cde6b784181b5b6d2c8.tar.gz
reaction-b8da93ebed6c17a1919d7cde6b784181b5b6d2c8.zip
cleanup of hard to read layout_args code
-rw-r--r--lib/Reaction/UI/ViewPort/Role/Actions.pm16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Reaction/UI/ViewPort/Role/Actions.pm b/lib/Reaction/UI/ViewPort/Role/Actions.pm
index 778115b..f2d40fb 100644
--- a/lib/Reaction/UI/ViewPort/Role/Actions.pm
+++ b/lib/Reaction/UI/ViewPort/Role/Actions.pm
@@ -63,17 +63,21 @@ sub _build_actions {
my $label = exists $proto->{label} ? $proto->{label} : $proto_name;
my $layout = exists $proto->{layout} ? $proto->{layout} : 'uri';
+ my $layout_args;
+ if( exists $proto->{layout_args} ){
+ if( ref($proto->{layout_args}) eq 'CODE' ){
+ $layout_args = $proto->{layout_args}->($target, $ctx);
+ } else {
+ $layout_args = $proto->{layout_args};
+ }
+ }
+
my $action = Reaction::UI::ViewPort::URI->new(
location => join ('-', $loc, 'action', $i++),
uri => ( ref($uri) eq 'CODE' ? $uri->($target, $ctx) : $uri ),
display => ( ref($label) eq 'CODE' ? $label->($target, $ctx) : $label ),
layout => $layout,
- exists $proto->{layout_args} ?
- ( ref($proto->{layout_args}) eq 'CODE' ?
- $proto->{layout_args}->($target, $ctx)
- :
- $proto->{layout_args} )
- : ()
+ ( ref($layout_args) eq ' HASH' ? layout_args => $layout_args : () ),
);
push(@act, $action);
}