++ed by:
KARUPA

1 PAUSE user

kfly8
and 1 contributors

NAME

Sub::Meta::Param - element of Sub::Meta::Parameters

SYNOPSIS

    use Sub::Meta::Param

    # specify all parameters
    my $param = Sub::Meta::Param->new(
        type     => 'Str',
        name     => '$msg',
        default  => 'world',
        coerce   => 0,
        optional => 0, # default
        named    => 0, # default
    );

    $param->type; # => 'Str'

    # omit parameters
    my $param = Sub::Meta::Param->new('Str');
    $param->type; # => 'Str'
    $param->positional; # => !!1
    $param->required;   # => !!1

METHODS

new

Constructor of Sub::Meta::Param.

    use Types::Standard -types;

    Sub::Meta::Param->new({
        type       => ArrayRef[Int],
        required   => 1,
        positional => 1,
    })

name

variable name, e.g. $msg, @list.

set_name(Str $name)

Setter for name.

type

Any type constraints, e.g. Str.

set_type($type)

Setter for type.

default

default value, e.g. "HELLO", sub { ... }

set_default($default)

Setter for default.

coerce

A boolean value indicating whether to coerce. Default to false.

set_coerce($bool)

Setter for coerce.

optional

A boolean value indicating whether to optional. Default to false. This boolean is the opposite of required.

set_optional($bool=true)

Setter for optional.

required

A boolean value indicating whether to required. Default to true. This boolean is the opposite of optional.

set_required($bool=true)

Setter for required.

named

A boolean value indicating whether to named arguments. Default to false. This boolean is the opposite of positional.

set_named($bool=true)

Setter for named.

positional

A boolean value indicating whether to positional arguments. Default to true. This boolean is the opposite of positional.

set_positional($bool=true)

Setter for positional.

is_same_interface($other_meta)

A boolean value indicating whether Sub::Meta::Param object is same or not. Specifically, check whether name, type, optional and named are equal.

SEE ALSO

Sub::Meta::Parameters

LICENSE

Copyright (C) kfly8.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

kfly8 <kfly@cpan.org>