Brick
view release on metacpan or search on metacpan
lib/Brick/Bucket.pm view on Meta::CPAN
print $brick->get_name, " --> $key\n";
print $brick->get_description, "\n";
}
1;
}
=back
=head2 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.
=over 4
=item use_field_labels( HASHREF )
Set the hash that C<get_field_label> uses to map field names to
field labels.
This method croaks if its argument isn't a hash reference.
=cut
sub use_field_labels {
croak "Not a hash reference!" unless UNIVERSAL::isa( $_[1], ref {} );
$_[0]->{_field_labels} = { %{$_[1]} };
}
=item get_field_label( FIELD )
Retrieve the label for FIELD.
=cut
sub get_field_label {
no warnings 'uninitialized';
$_[0]->{_field_labels}{ $_[1] };
}
=item set_field_label( FIELD, VALUE )
Set the label for FIELD to VALUE. It returns VALUE.
=cut
sub set_field_label {
$_[0]->{_field_labels}{ $_[1] } = $_[2];
}
sub __caller_chain_as_list {
my $level = 0;
my @Callers = ();
while( 1 ) {
my @caller = caller( ++$level );
last unless @caller;
push @Callers, {
level => $level,
package => $caller[0],
'sub' => $caller[3] =~ m/(?:.*::)?(.*)/,
};
}
#print STDERR Data::Dumper->Dump( [\@Callers], [qw(callers)] ), "-" x 73, "\n";
@Callers;
}
=back
=head1 Brick::Bucket::Entry
=cut
package Brick::Bucket::Entry;
use Carp qw(carp);
=over 4
=item my $entry = Brick::Bucket::Entry->new( HASHREF )
=cut
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->{comprises} ||= [];
$self;
}
=item $entry->get_gv()
Get the GV object associated with the entry. The GV object comes from
the svref_2object(SVREF) function in the C<B> module. Use it to get
information about the coderef's creation.
my $entry = $bucket->get_entry( $coderef );
my $gv = $entry->get_gv;
printf "$coderef comes from %s line %s\n",
map { $gv->$_ } qw( FILE LINE );
The C<B> documentation explains what you can do with the GV object.
=cut
sub get_gv { $_[0]->{gv} || Object::Null->new }
=item $entry->get_name()
( run in 1.636 second using v1.01-cache-2.11-cpan-ceb78f64989 )