Brick::Selectors

Brick::Selectors is a Perl module that helps you connect the input data to the closures in the pool.
Download

Brick::Selectors Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • brian d foy
  • Publisher web site:
  • http://search.cpan.org/~bdfoy/

Brick::Selectors Tags


Brick::Selectors Description

Brick::Selectors is a Perl module that helps you connect the input data to the closures in the pool. Brick::Selectors is a Perl module that helps you connect the input data to the closures in the pool.SYNOPSIS use Brick::Selectors;Selectors test a condition, but they don't fail if the test doesn't work. Instead of die-ing, they return 0. Composers can use selectors to decide if they want to continue with the rest of the composition or simply skip it and try something else. This requires something like Brick::Composers::__compose_pass_or_skip or Brick::Composers::__compose_pass_or_stop that are designed to handle selectors.The basic use goes like this. I'll make up the completely fake situation where I have to validate a number from user input. If it's odd, It has to be greater than 11 and prime. If it's even, it has to be less than 20 and it has to be a tuesday. Here's the tree of decisions: some value / / odd even / | | _is_prime -------+ | | +----- _is_tueday | | / / > 11 < 20Now, I have to compose subroutines that will do the right thing. The first step is to decide which side of the tree to process. I'll make some selectors. These won't die if they don't pass: my $even_selector = $bucket->_is_even_number; my $odd_selector = $bucket->_is_even_number;I put the selectors together with the subroutines that should run if that selector is true. The selector tells __compose_pass_or_stop to skip the rest of the subroutines without die-ing. The branch effectively turns into a null operation. my $even_branch = $brick->__compose_pass_or_stop( $even_selector, $brick->_is_tuesday, ); my $odd_branch = $brick->__compose_pass_or_stop( $odd_selector, $brick->_is_prime( { field => 'number_field_name' } ), );I put the branches together, perhaps with __compose_pass_or_skip. When the first branch runs, if the value isn't even then the selector stops the subroutine in $even_branch and control skips to $odd_branch. my $tester = $brick->__compose_pass_or_skip( $even_branch, $odd_branch, );Requirements:· Perl Requirements: · Perl


Brick::Selectors Related Software