Type::API::Constraint::Inlinable - allows a string of code to be generated to check a given variable
Implementations of Type::API::Constraint::Inlinable MUST also implement Type::API::Constraint.
Implementations MUST provide the following methods:
$constraint->can_be_inlined
Returns a boolean indicating whether inlining support is available for this type constraint.
$constraint->inline_check($variable_name)
$variable_name will be a string such as '$_' or '$_[0]'. Should return a string of code that may be evaluated to determine the pass/failure of the value in the given variable. The string MUST NOT include return, goto or other flow control keywords that would make it unsuitable for inlining into a larger function.
$variable_name
'$_'
'$_[0]'
return
goto
There is not currently any mechanism to request that the string of code in a particular programming language, nor a mechanism for the implementation to indicate what language it has generated. However, the implementations that have been investigated have returned Perl 5 code. Nevertheless, this is an area for further investigation.
Implementations MAY advertise that they support this interface by returning true for $constraint->DOES("Type::API::Constraint::Inlinable").
MAY
$constraint->DOES("Type::API::Constraint::Inlinable")
The following CPAN classes are known to implement Type::API::Constraint::Inlinable:
Specio::Constraint::Simple (and several other classes in the Specio distribution)
Type::Tiny (and its subclasses)
The following CPAN classes implement this interface with a minor difference; the inline_check method is called _inline_check instead. Tools wishing to make use of this interface should consider supporting this variation.
inline_check
_inline_check
Moose::Meta::TypeConstraint (and its subclasses)
MooseX::Meta::TypeDecorator
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Type::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Type::API
CPAN shell
perl -MCPAN -e shell install Type::API
For more information on module installation, please visit the detailed CPAN module installation guide.