File: Context.pm

package info (click to toggle)
libjson-pointer-perl 0.07-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 252 kB
  • sloc: perl: 578; makefile: 2
file content (110 lines) | stat: -rw-r--r-- 1,946 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package JSON::Pointer::Context;

use 5.008_001;
use strict;
use warnings;
use Class::Accessor::Lite (
    new => 0,
    rw  => [
        qw/
              pointer
              tokens
              processed_tokens
              last_token
              last_error
              result
              target
              parent
          /
      ],
);

our $VERSION = "0.07";

sub new {
    my $class = shift;
    my $args = ref $_[0] ? $_[0] : +{ @_ };
    %$args = (
        tokens           => [],
        processed_tokens => [],
        last_token       => undef,
        last_error       => undef,
        result           => 0,
        target           => undef,
        parent           => undef,
        %$args,
    );
    bless $args => $class;
}

sub begin {
    my ($self, $token) = @_;
    $self->{last_token} = $token;
    ### assign before target into parent
    $self->{parent} = $self->{target};
}

sub next {
    my ($self, $target) = @_;
    $self->{target} = $target;
    push(@{$self->{processed_tokens}}, $self->{last_token});
}

1;

__END__

=head1 NAME

JSON::Pointer::Context - Internal context object to process JSON Pointer

=head1 VERSION

This document describes JSON::Pointer::Context version 0.07.

=head1 SYNOPSIS

=head1 DESCRIPTION

This module is internal only.

=head1 METHODS

=head2 new(%args) :JSON::Pointer::Context

=head2 begin($token)

=head2 next($target)

=head1 DEPENDENCIES

Perl 5.8.1 or later.

=head1 BUGS

All complex software has bugs lurking in it, and this module is no
exception. If you find a bug please either email me, or add the bug
to cpan-RT.

=head1 SEE ALSO

=over

=item L<perl>

=item L<Class::Accessor::Lite>

=back

=head1 AUTHOR

Toru Yamaguchi E<lt>zigorou at cpan.orgE<gt>

=head1 LICENSE AND COPYRIGHT

Copyright (c) 2013, Toru Yamaguchi. All rights reserved.

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

=cut