App::Rad::Plugin::ValuePriority - A Plugin to make it easy to get value from all acessors.
Version 0.02
use App::Rad qw/ValuePriority/; sub command_1 { my $c = shift; $c->stash->{value_1} = "Test 01"; $c->default_value->{value_2} = "Test 02"; return join " --- ", $c->value->{value_1}, $c->value->{value_2}, $c->value->{value_3}; # It will print Test 01 --- Test 02 --- # but if you call program like this: # ./my_app.pl command_1 --value_2="Option 02" --value_3="Option 03" # it will print: # Test 01 --- Option 02 --- Option 03 } sub command_2 { my $c = shift; $c->stash->{value_1} = "Test 01"; $c->default_value->{value_2} = "Test 02"; $c->to_stash; return join " --- ", $c->stash->{value_1}, $c->stash->{value_2}, $c->stash->{value_3}; # It will print Test 01 --- Test 02 --- # but if you call program like this: # ./my_app.pl command_2 --value_2="Option 02" --value_3="Option 03" # it will print: # Test 01 --- Option 02 --- Option 03 }
Internal func
It is a acessor. You use it to set and get some key/value pairs.
It receives a ordered list of what should receive priority. The options are: options, config, stash, default_value And that is the default order.
As the name says, it return the priority order. As a arrayref
it populate the $c->stash with the values obeying the setted order.
Return the value obeying the setted order.
To install App::Rad::Plugin::ValuePriority, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Rad::Plugin::ValuePriority
CPAN shell
perl -MCPAN -e shell install App::Rad::Plugin::ValuePriority
For more information on module installation, please visit the detailed CPAN module installation guide.