Sub::Meta::Param - element of Sub::Meta::Parameters
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
Constructor of Sub::Meta::Param.
Sub::Meta::Param
use Types::Standard -types; Sub::Meta::Param->new({ type => ArrayRef[Int], required => 1, positional => 1, })
method name() => Str
variable name, e.g. $msg, @list.
$msg
@list
method has_name() => Bool
Whether Sub::Meta::Param has name or not.
method set_name(Str $name) => $self
Setter for name.
name
method type() => Any
Any type constraints, e.g. Str.
Str
method has_type() => Bool
Whether Sub::Meta::Param has type or not.
method set_type(Any $type) => $self
Setter for type.
type
The alias of type
The alias of set_type
set_type
method default() => Any
default value, e.g. "HELLO", sub { ... }
"HELLO"
sub { ... }
method has_default() => Bool
Whether Sub::Meta::Param has default or not.
method set_default(Any $default) => $self
Setter for default.
default
method coerce() => Any
A boolean value indicating whether to coerce. Default to false.
method has_coerce() => Bool
Whether Sub::Meta::Param has coerce or not.
method set_coerce(Any $coerce) => $self
Setter for coerce.
coerce
method optional() => Bool
A boolean value indicating whether to optional. Default to false. This boolean is the opposite of required.
required
method set_optional(Bool $bool=true) => $self
Setter for optional.
optional
method required() => Bool
A boolean value indicating whether to required. Default to true. This boolean is the opposite of optional.
method set_required(Bool $bool=true) => $self
Setter for required.
method named() => Bool
A boolean value indicating whether to named arguments. Default to false. This boolean is the opposite of positional.
positional
method set_named(Bool $bool=true) => $self
Setter for named.
named
method positional() => Bool
A boolean value indicating whether to positional arguments. Default to true. This boolean is the opposite of positional.
method set_positional(Bool $bool=true) => $self
Setter for positional.
method invocant() => Bool
A boolean value indicating whether to be invocant. Default to false.
method set_invocant(Bool $bool=true) => $self
Setter for invocant.
invocant
method is_same_interface(InstanceOf[Sub::Meta::Param] $other_meta) => Bool
A boolean value indicating whether Sub::Meta::Param object is same or not. Specifically, check whether name, type, optional and named are equal.
method is_same_interface_inlined(InstanceOf[Sub::Meta::Param] $other_meta) => Str
Returns inlined is_same_interface string.
is_same_interface
method display() => Str
Returns the display of Sub::Meta::Param:
use Sub::Meta::Param; use Types::Standard qw(Str); my $meta = Sub::Meta::Param->new( type => Str, name => '$message', ); $meta->display; # 'Str $message'
Sub::Meta::Parameters
Copyright (C) kfly8.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
kfly8 <kfly@cpan.org>
To install Sub::Meta, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Meta
CPAN shell
perl -MCPAN -e shell install Sub::Meta
For more information on module installation, please visit the detailed CPAN module installation guide.