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

Data::Visitor::Lite - an easy implementation of Data::Visitor::Callback

SYNOPSIS

    use Data::Visitor::Lite;
    my $visitor = Data::Visitor::Lite->new($replacer);

    my $value = $visitor->visit({ 
      # some structure
    });

DESCRIPTION

Data::Visitor::Lite is an easy implementation of Data::Visitor::Callback

new(@replacers)

this is a constructor of Data::Visitor::Lite.

    my $visitor = Data::Visitor::Lite->new(
        # '-implements' replacer type means only replace 
        #   when an object can implements provided methods
        [-implements => ['to_plain_object'] => sub {$_[0]->to_plain_object}],

        # '-isa' replace type means only replace 
        #   when an object is a sub-class of provided package,
        [-instance => 'Some::SuperClass' => sub{$_[0]->encode_to_utf8}]

        # '-number' replace type means only replace 
        [-value => sub{ $_[0]+1}]

    );

    my $value = $visitor->visit({ something });

AUTHOR

Daichi Hiroki <hirokidaichi {at} gmail.com>

SEE ALSO

Data::Visitor::Callback

LICENSE

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