NAME

Data::Pretty::FilterContext - Data Dump Beautifier Filter Context

SYNOPSIS

use Data::Pretty::FilterContext;
my $ctx = Data::Pretty::FilterContext->new( $rval, $class, $type, $ref, $pclass, $pidx, $idx );

VERSION

v0.1.0

DESCRIPTION

The context object provide methods that can be used to determine what kind of object is currently visited and where it is located. The context object has the following interface

CONSTRUCTOR

new

This takes the following arguments and returns the newly instantiated object.

  • $rval

    The value passed as a reference.

  • $class

    The object class, if any.

  • $type

    The data type, such as ARRAY, CODE, GLOB, HASH, REF, REGEXP, SCALAR or VSTRING

  • $ref

    The data reference as returned by "ref" in perlfunc

  • $pclass

    A container class, if any

  • $pidx

  • $idx

METHODS

object_ref

Alternative way to obtain a reference to the current object

class

If the object is blessed this return the class. Returns "" for objects not blessed.

reftype

Returns what kind of object this is. It's a string like ARRAY, CODE, GLOB, HASH, REF, REGEXP, SCALAR or VSTRING

is_ref

Returns true if a reference was provided.

is_blessed

Returns true if the object is blessed. Actually, this is just an alias for $ctx->class.

is_array

Returns true if the object is an array

is_hash

Returns true if the object is a hash

is_scalar

Returns true if the object is a scalar (a string or a number)

is_code

Returns true if the object is a function (aka subroutine)

container_class

Returns the class of the innermost container that contains this object. Returns "" if there is no blessed container.

container_self

Returns an textual expression relative to the container object that names this object. The variable $self in this expression is the container itself.

object_isa( $class )

Returns TRUE if the current object is of the given class or is of a subclass.

container_isa( $class )

Returns TRUE if the innermost container is of the given class or is of a subclass.

depth

Returns how many levels deep have we recursed into the structure (from the original dump_filtered() arguments).

expr

expr( $top_level_name )

Returns an textual expression that denotes the current object. In the expression $var is used as the name of the top level object dumped. This can be overridden by providing a different name as argument.

SEE ALSO

Data::Pretty

CREDITS

Credits to Gisle Aas for the original Data::Dump version and to Breno G. de Oliveira for maintaining it.

COPYRIGHT & LICENSE

Copyright(c) 2023 DEGUEST Pte. Ltd.

All rights reserved

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