Trystan Johnson > Farly-0.25 > Farly::Object::List

Download:
Farly-0.25.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.25   Source   Latest Release: Farly-0.26

NAME ^

Farly::Object::List - Searchable container of Farly::Objects

SYNOPSIS ^

  use Farly::Object::List;
  use Farly::Object;
  use Farly::Value::String;
  
  my $object_1 = Farly::Object->new();
  $object_1->set( "id",        Farly::Value::String->new("id1234") );
  $object_1->set( "last_name", Farly::Value::String->new("Hofstadter") );
  my $object_n = Farly::Object->new();    

  $object_n->set( "id", Farly::Value::String->new("id9999") );

  my $container = Farly::Object::List->new();

  $container->add( $object_1 );
  $container->add( $object_n );

  my $search = Farly::Object->new();
  $search->set( "id", Farly::Value::String->new("id1234") );

  my $search_result = Farly::Object::List->new();

  $container->matches( $search, $search_result );

  foreach my $object ( $search_result->iter() ) {
      print $object->get("last_name")->as_string() if ( $object->has_defined("last_name") );
      print "\n";
  }

DESCRIPTION ^

Farly::Object::List is a searchable 'ARRAY' based container of Farly::Objects.

METHODS ^

new()

The constructor.

   my $container = Farly::Object::List->new();

No arguments.

add( <Farly::Object> )

Add a new Farly::Object object to the container.

  $container->add( $object ); 

clone()

Return a new Farly::Object::List of cloned Farly::Object objects

  my $new_container = $container->clone(); 

Farly::Object->clone() does not clone the value objects in the Farly::Object container elements.

iter()

Returns 'ARRAY' of the Farly::Object container elements.

  my @objects = $container->iter();

includes( $object<Farly::Object> )

Returns true if an object in this List 'matches' the other object.

  $set1->includes( $object );

matches( $search<Farly::Object>, $result<Farly::Object::List> )

Store all objects which match $search in $result.

  $container->matches( $search, $result );

contains( $search<Farly::Object>, $result<Farly::Object::List> )

Store all objects which contain $search in $result.

  $container->contains( $search, $result );

contained_by( $search<Farly::Object>, $result<Farly::Object::List> )

Store all objects which are contained by $search in $result.

  $container->contained_by( $search, $result );

search( $search<Farly::Object>, $result<Farly::Object::List> )

Store all objects which match, contain, are contained by, or intersect $search in $result.

Applies matches, contains, contained_by, and intersects methods in that order.

  $container->search( $search, $result );

size()

Returns a count of the number of objects currently in the container.

  my $size = $container->size();

COPYRIGHT AND LICENCE ^

Farly::Object::List Copyright (C) 2013 Trystan Johnson

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

syntax highlighting: