NAME
Util::Underscore::Objects - Functions for introspecting and manipulating objects and classes
VERSION
version v1.4.2
FUNCTION REFERENCE
$str = _::blessed $obj$str = _::blessed$str = _::class $obj$str = _::class-
Accesses the class of the provided object.
Wrapper for
Scalar::Util::blessed.$obj: the object of which the class is to be determined. If omitted, uses
$_.returns: The class of
$objif that is a blessed scalar, else returnsundef. $bool = _::is_object $scalar$bool = _::is_object-
Checks that the argument is a blessed object. It's just an abbreviation for
defined _::blessed $scalar.$scalar: the scalar which may or may not be a blessed object.
returns: a boolean indicating whether the
$scalaris a blessed object. $bool = _::class_isa $class, $supertype-
Checks that the
$classinherits from the given$supertype, both given as strings. In most cases, one should use_::class_doesinstead.$class: the name of the class.
$supertype: the name of another class.
returns: a boolean indicating whether
$classinherits from$supertype. $bool = _::class_does $class, $role-
Checks that the
$classperforms the given$role, both given as strings. This means that the$classhas a compatible interface to the$role. However, this does not require that the$classinherits from the$role.$class: the name of the class.
$role: the name of a role.
returns: a boolean indicating whether
$classconforms to the$role. $bool = _::isa $object, $class-
Checks that the
$objectinherits from the given class. In most cases, one should use_::doesor_::is_instanceinstead.$object: a scalar possibly containing an object.
$class: the name of a class:
returns: a boolean indicating whether the
$objectinherits from the given$class. Returns false if the$objectparameter isn't actually an object. $code = _::can $object, $method-
Checks that the object can perform the given method.
if (my $code = _::can $object, $method) { $object->$method(@args); }$object: a scalar.
$method: the name of the method to search.
returns: if the
$objectcan perform the$method, this returns a reference to that method. A false value is returned in all other cases (the object doesn't know about that method, or the$objectargument doesn't actually hold an object). $bool = _::is_instance $object, $role$bool = _::does $object, $role-
Checks that the given
$objectcan perform the$role.$object: a scalar possibly containing an object.
$role: the name of a role.
returns: a boolean value indicating whether the given
$objectconforms to the$role. any = $maybe_object->_::safecall(method => @args)-
This will call the
methodonly if the$maybe_objectis a blessed object. We do not check that the objectcanperform the method, so this might still raise an exception.Context is propagated correctly to the method call. If the
$maybe_objectis not an object, this will simply return. In scalar context, this evaluates toundef, in list context this is the empty list.
BUGS
Please report any bugs or feature requests on the bugtracker website https://github.com/latk/p5-Util-Underscore/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
AUTHOR
Lukas Atkinson (cpan: AMON) <amon@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Lukas Atkinson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.