The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Iterator::Flex::Role::Utils - Role based utilities

VERSION

version 0.18

DESCRIPTION

This is a Role::Tiny role which adds a variety of utility methods to a class. They are structured that way so that they may be overridden if necessary. (Well, technically under-ridden if they already exist before this role is applied).

CLASS METHODS

_load_module

  $module = $class->_load_module( $module, ?\@namespaces );

Loads the named module. If $module begins with a + it is assumed to be a fully qualified module name, otherwise it is searched for in the namespaces provided by @namespaces (which defaults to the namespaces returned by the _namespaces class method.

Throws Iterator::Flex::Failure::class if it couldn't require the module (for whatever reason).

_load_role

  $module = $class->_load_role( $role );

Loads the named role. If $role begins with a +, it is assumed to be a fully qualified name, otherwise it is searched for in the namespaces returned by the _role_namespaces class method.

_can_meth

  $code = $class->_can_meth( @methods, ?\%pars  );
  $code = $class->_can_meth( $obj, @method, ?\%pars );

Scans an object to see if it provides one of the specified methods. For each $method in @methods, it probes for __$method__, then $method.

By default, it returns a reference to the first method it finds, otherwise undef if none was found.

The return value can be altered using %pars.

name

return the name of the method.

code

return the coderef of the method. (Default)

If both code and name are specified, both are returned as a list, name first:

  ($name, $code ) = $class->_can_meth( $obj, @methods, {name => 1, code => 1 } );

_resolve_meth

  $code = $obj->_resolve_meth( $target, $method, @fallbacks );

Return a coderef to the specified method or one of the fallbacks.

If $method is a coderef, it is returned.

If $method is defined and is not a coderef, it is checked for directly via $target-can>. If it does not exist, a Iterator::Flex::Failure::parameter error is thrown.

If $method is not defined, then $obj->_can_meth( $target, @fallbacks ) is returned.

METHODS

_throw

  $obj->_throw( $type => $message );

Throw an exception object of class Iterator::Flex::Failure::$type with the given message.

INTERNALS

SUPPORT

Bugs

Please report any bugs or feature requests to bug-iterator-flex@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=Iterator-Flex

Source

Source is available at

  https://gitlab.com/djerius/iterator-flex

and may be cloned from

  https://gitlab.com/djerius/iterator-flex.git

SEE ALSO

Please see those modules/websites for more information related to this module.

AUTHOR

Diab Jerius <djerius@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.

This is free software, licensed under:

  The GNU General Public License, Version 3, June 2007