Acme-Sub-Parms

 view release on metacpan or  search on metacpan

examples/object_use_example.pl  view on Meta::CPAN

#############################################
# object instance constructor with two parameters
# 
#   'thing'       which is optional and defaults to "Something Blue" if not passed
#   'other_thing' which is required and cannot be the undef value
#
sub new {
    my $proto   = shift;
    my $package = __PACKAGE__;
    my $class   = ref($proto) || $proto || $package;
    my $self    = bless {}, $class;

    BindParms : (
        my $thing : thing       [optional, default="Something Blue"];
        my $other : other_thing [required, is_defined];
    )
    $self->thing($thing);
    $self->other_thing($other);
    return $self;
}

lib/Acme/Sub/Parms.pm  view on Meta::CPAN

    foreach my $item (@_) {
        if (not _legal_option($item)) {
            my $package = __PACKAGE__;
            require Carp;
            Carp::croak("'$item' not a valid option for 'use $package'\n");
        }
        $options->{$item} = 1;
    }
    $Acme::Sub::Parms::line_counter = 0;
    my $ref   = {'options' => $options, 'bind_block' => 0 };
    filter_add(bless $ref); # imported from Filter::Util::Call
}

####

sub _parse_bind_spec {
    my ($self, $raw_spec) = @_;

    my $spec = $raw_spec;

    my $spec_tokens = {

lib/Acme/Sub/Parms.pod  view on Meta::CPAN

  )

=back

=over 4

=item type=classname | type="type1 type2 type3 ..."

The 'type' declaration generates a validation requirement that a passed
value is an instance of the specified type. This is an B<exact match>
requirement. It does not check for class inheritance or blessed objects.
If you specify a reference type or a class name it must match B<exactly>.

This can also be used for checking Perl's built-in reference types such
as 'HASH', 'ARRAY' or 'CODE'.

Note: This B<does not> verify that anything _was_ passed, only that
B<if> something was passed, it is of the specified type.

Examples:

t/01_validating.t  view on Meta::CPAN


###

package Acme::Sub::Parms::TestObject;

sub param {
    1;
}

sub new {
    my $self = bless {}, 'Acme::Sub::Parms::TestObject';
    return $self;
}


t/02_no_validation.t  view on Meta::CPAN


###

package Acme::Sub::Parms::TestObject;

sub param {
    1;
}

sub new {
    my $self = bless {}, 'Acme::Sub::Parms::TestObject';
    return $self;
}


t/03_normalized_validating.t  view on Meta::CPAN


###

package Acme::Sub::Parms::TestObject;

sub param {
    1;
}

sub new {
    my $self = bless {}, 'Acme::Sub::Parms::TestObject';
    return $self;
}


t/04_normalized_no_validation.t  view on Meta::CPAN


###

package Acme::Sub::Parms::TestObject;

sub param {
    1;
}

sub new {
    my $self = bless {}, 'Acme::Sub::Parms::TestObject';
    return $self;
}




( run in 1.064 second using v1.01-cache-2.11-cpan-de7293f3b23 )