Brick::Bucket - the thing that keeps everything straight.
SYNOPSIS
use Brick::Bucket;
my $bucket = Brick::Bucket->new();
Class methods
new()
Creates a new bucket to store Brick constraints
entry_class
Although this is really a class method, it's also an object method because Perl doesn't know the difference. The return value, however, isn't designed to be mutable. You may want to change it in a subclass, but the entire system still needs to agree on what it is. Since I don't need to change it (although I don't want to hard code it either), I have a method for it. If you need something else, figure out the consequences and see if this could work another way.
Object methods
add_to_bucket( HASHREF )
add_to_pool # DEPRECATED
You can pass these entries in the HASHREF:
code - the coderef to add to the bucket
name - a name for the entry, which does not have to be unique
description - explain what this coderef does
args - a reference to the arguments that the coderef closes over
fields - the input field names the coderef references
unique - this name has to be unique
If you pass a true value for the unique value, then there can't be any other brick with that name already, or a later brick which tries to use the same name will fail.
The method adds these fields to the entry:
gv - a GV reference from B::svref_2object($sub), useful for
finding where an anonymous coderef came from
created_by - the name of the routine that added the entry to the bucket
It returns the subroutine reference.
get_from_bucket( CODEREF )
Gets the entry for the specified CODEREF. If the CODEREF is not in the bucket, it returns false.
The return value is an entry instance.
get_brick_by_name( NAME )
Gets the code references for the bricks with the name NAME. Since bricks don't have to have a unique name, it might return more than one.
In list context return the bricks with NAMe, In scalar context returns the number of bricks it found.
get_all_keys
Returns an unordered list of the keys (entry IDs) in the bucket. Although you probably know that the bucket is a hash, use this just in case the data structure changes.
comprise( COMPOSED_CODEREF, THE_OTHER_CODEREFS )
Tell the bucket that the COMPOSED_CODEREF is made up of THE_OTHER_CODEREFS.
$bucket->comprise( $sub, @component_subs );
dump_bucket
Show the names and descriptions of the entries in the bucket. This is mostly a debugging tool.
Field labels
The bucket can store a dictionary that maps field names to arbitrary strings. This way, a brick can translate and input parameter name (e.g. a CGI input field name) into a more pleasing string for humans for its error messages. By providing methods in the bucket class, every brick has a chance to call them.
use_field_labels( HASHREF )
Set the hash that get_field_label uses to map field names to field labels.
This method croaks if its argument isn't a hash reference.
get_field_label( FIELD )
Retrieve the label for FIELD.
set_field_label( FIELD, VALUE )
Set the label for FIELD to VALUE. It returns VALUE.
Product's homepage
Requirements:
· Perl