| EO documentation | Contained in the EO distribution. |
EO::Collection - abstract base class for Collection-type objects
EO::Collection is an base class for things that want to implement a collection class.
Thrown when invalid parameters are passed to a method.
EO::Collection inherits from EO.
EO::Collection provides no constructor beyond what its parent class provides.
This gets and sets the raw Perl primitive that is going to be used for storage. An attempt to set this to something other than a reference will result in a EO::Error::InvalidParameters exception being thrown.
Returns a string representation of the object useful for debugging purposes.
Abstract method that needs to be implemented in child classes. Should delete the thing located at element KEY.
Abstract method that needs to be implemented in child classes. With one argument should return the thing located at element KEY. With two arguments it should place THING in location KEY.
EO::Array, EO::Hash
James A. Duncan <jduncan@fotango.com
Copyright 2003 Fotango Ltd.
| EO documentation | Contained in the EO distribution. |
package EO::Collection; use strict; use warnings; use EO; use EO::Error; our $VERSION = 0.96; our @ISA = qw( EO ); exception EO::Error::InvalidParameters; sub element { my $self = CORE::shift; if (@_) { my $thing = shift; if (!ref($thing)) { throw EO::Error::InvalidParameters text => 'not a reference'; } $self->{ element } = $thing; return $self; } return $self->{ element }; } sub delete : Abstract; sub at : Abstract; sub count : Abstract; sub select : Abstract; sub do : Abstract; sub grep { my $self = shift; $self->select( @_ ); } sub foreach { my $self = shift; $self->do( @_ ); } sub as_string { my $self = shift; use Data::Dumper qw(); my $d = Data::Dumper->new([ $self->element ]); $d->Indent( 0 ); my $str = $d->Dump; $str =~ s/\$VAR\d\s*=\s*//g; return $str; } 1; __END__