brian d foy > Brick-0.226_02 > Brick::Constraints

Download:
Brick-0.226_02.tar.gz

Dependencies

Annotate this POD

Module Version: 1.2264   Source  

NAME ^

Brick::Constraints - Connect the input data to the closures in the pool

SYNOPSIS ^

        use Brick;

DESCRIPTION ^

__make_constraint( CODEREF, INPUT_HASH_REF )

Turn a closure into a constraint by providing the bridge between the input hash and code reference.

Call this in your top level generator after you have composed all the pieces you want.

__make_dfv_constraint

Adapter for Data::FormValidator

sub __make_dfv_constraint # may need to change name to make generic { my( $bucket, $validator, $hash ) = @_;

        $hash ||= {};

        my @callers = main::__caller_chain_as_list();

        my $name = $hash->{profile_name} || $callers[-1]{'sub'} || 'Anonymous';

        unless(
                eval { $validator->isa( ref sub {} ) }    or
                UNIVERSAL::isa( $validator, ref sub {} )
                )
        {
        carp( "Argument to $callers[1]{'sub'} must be a code reference [$validator]: $@" );
        return $bucket->add_to_bucket( { code => sub {}, name => "Null subroutine",
                description => "This sub does nothing, because something didn't happen correctly."
                } );
                }

    my $constraint = $bucket->add_to_bucket( {
        name        => $name,
        description => "Data::FormValidator constraint sub for $callers[-1]{'sub'}",

        code        => sub {
                        my( $dfv ) = @_;

                        $dfv->name_this( $callers[-1]{'sub'} );
                        my( $field, $value ) = map {
                                $dfv->${\ "get_current_constraint_$_"}
                                } qw(field value);

                        my $hash_ref = $dfv->get_filtered_data;

                        return unless $validator->( $hash_ref );

                        return $field;
                        },
                } );

    $bucket->comprise( $constraint, $validator );

    return $constraint;
        }

TO DO ^

TBA

SEE ALSO ^

TBA

SOURCE AVAILABILITY ^

This source is part of a SourceForge project which always has the latest sources in SVN, as well as all of the previous releases.

        svn co https://brian-d-foy.svn.sourceforge.net/svnroot/brian-d-foy brian-d-foy

If, for some reason, I disappear from the world, one of the other members of the project can shepherd this module appropriately.

AUTHOR ^

brian d foy, <bdfoy@cpan.org>

COPYRIGHT ^

Copyright (c) 2007, brian d foy, All Rights Reserved.

You may redistribute this under the same terms as Perl itself.

syntax highlighting: