NAKAGAWA Masaki > Data-OpenStruct-Deep-0.03 > Data::OpenStruct::Deep

Download:
Data-OpenStruct-Deep-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Data::OpenStruct::Deep - allows you to create data objects and set arbitrary attributes deeply

SYNOPSIS ^

    use Data::OpenStruct::Deep;

    my %hash = (
        foo => 1,
        bar => {
            baz => 2,
        },
    );

    my $struct = Data::OpenStruct::Deep->new(%hash);
    my $foo = $struct->foo;      #=> 1
    my $bar = $struct->bar;      #=> { baz => 2 }
    my $baz = $struct->bar->baz; #=> 2

    my $empty = Data::OpenStruct::Deep->new;
    $empty->foo->bar->baz->quux('deeply'); # deeply, ok
    print $empty->foo->bar;            #=> { baz => { quux => "deeply" } }
    print $empty->foo->bar->baz->quux; #=> "deeply"

DESCRIPTION ^

This module allows you to create data objects and set arbitrary attributes.

It is like a hash with a different way to access the data. In fact, it is implemented with a hash and AUTOLOAD, and you can initialize it with one.

METHODS ^

new(%hash?)

to_hash

AUTHOR ^

NAKAGAWA Masaki <masaki@cpan.org>

LICENSE ^

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

SEE ALSO ^

Hash::AsObject, Object::AutoAccessor, Hash::Inflator,

http://www.ruby-doc.org/stdlib/libdoc/ostruct/rdoc/classes/OpenStruct.html

syntax highlighting: