++ed by:

1 non-PAUSE user.

James A. Duncan
and 1 contributors

NAME

EO::Hierarchy - hierarchical data structures

SYNOPSIS

  my $foo = EO::Hierarchy->new;
  $foo->at( 'bar', 'baz' );
  $foo->add_child( 'frob' );
  $foo->at( 'frob' )->at( 'bar' ); ## eq 'baz'

  ## or

  my $foo = EO::Hierarchy->new;
  $foo->delegate( EO::Array->new );
  $foo->at( 0, 'baz' );
  $foo->add_child( 1 );
  $foo->at( 1 )->at( 0 ); ## eq 'baz'

DESCRIPTION

EO::Hierarchy delegates to a collection object to provide heritable data structures. It should be noted that these data structures can appear recursive without being so. This is demonstrable with the following code example:

  my $obj = EO::Hierarchy->new;
  $obj->add_child( 'foo' );
  my $recurse = $obj->at('foo');
  print "appears recursive" if $recurse == $recurse->at('foo')

Handily the above code sample also displays a mechanism for testing it.

METHODS

EO::Hierarchy inherits from EO and shares all of its methods. EO::Hierarchy uses the EO::delegate pattern and shares the functionality of it. It provides a default delegation to an EO::Hash object which is constructed as a result of creating an EO::Hierarchy object.

add_child( KEY )

Adds a child into the data structure at the key KEY. The child is also a EO::Hierarchy object that inherits its data from the parent. If you don't want an inheriting child then you should use the at method, as you would with a normal EO::Collection object.

AUTHOR

James A. Duncan <jduncan@fotango.com>

COPYRIGHT

Copyright 2005 Fotango Ltd. All Rights Reserved.