Acrux

 view release on metacpan or  search on metacpan

lib/Acrux/Pointer.pm  view on Meta::CPAN

package Acrux::Pointer;
use strict;
use utf8;

=encoding utf8

=head1 NAME

Acrux::Pointer - The Acrux pointer

=head1 SYNOPSIS

    use Acrux::Pointer;

    my $pointer = Acrux::Pointer->new(data => {foo => [123, 'bar']});

    say $pointer->get('/foo/1');
    say 'Contains "/foo".' if $pointer->contains('/foo');

=head1 DESCRIPTION

This class is an implementation of L<RFC 6901|https://tools.ietf.org/html/rfc6901>
for perl hash-structures

=head2 new

    my $pointer = Acrux::Pointer->new;
    my $pointer = Acrux::Pointer->new(data => {foo => 'bar'});

Build new Acrux::Pointer object

=head1 ATTRIBUTES

This class implements the following attributes

=head2 data

    my $data = $pointer->data;
    $pointer = $pointer->data({foo => 'bar'});

Data structure to be processed

=head1 METHODS

This class implements the following methods

=head2 contains

    my $bool = $pointer->contains('/foo/1');

Check if L</"data"> contains a value that can be identified with the given pointer

=head2 get

    my $value = $pointer->get('/foo/bar');

Extract value from L</"data"> identified by the given pointer

    # "just a string"
    Acrux::Pointer->new(data => 'just a string')->get();

    # "bar"
    Acrux::Pointer->new(data => {foo => 'bar', baz => [4, 5, 6]})->get('/foo');

    # "4"



( run in 1.183 second using v1.01-cache-2.11-cpan-5837b0d9d2c )