| 1 | # POD documentation - main docs before the code | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | GenOO::RegionCollection::Factory::RegionArray - Factory for creating a RegionCollection from array of regions | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | # Creates GenOO::RegionCollection from a array of L<Region> objects | ||
| 10 | |||
| 11 | # Preferably use it through the generic GenOO::RegionCollection::Factory | ||
| 12 | my $factory = GenOO::RegionCollection::Factory->new('RegionArray', | ||
| 13 | { | ||
| 14 | array => \@array_with_regions | ||
| 15 | } | ||
| 16 | ); | ||
| 17 | |||
| 18 | =head1 DESCRIPTION | ||
| 19 | |||
| 20 | An instance of this class is a concrete factory for the creation of a | ||
| 21 | L<GenOO::RegionCollection> from an array of L<Region> objects. It offers the method | ||
| 22 | "read_collection" (as the consumed role requires) which returns the actual | ||
| 23 | L<GenOO::RegionCollection> object in the form of | ||
| 24 | L<GenOO::RegionCollection::Type::DoubleHashArray>. The latter is the implementation | ||
| 25 | of the L<GenOO::RegionCollection> class based on the complex data structure | ||
| 26 | L<GenOO::Data::Structure::DoubleHashArray>. | ||
| 27 | |||
| 28 | =head1 EXAMPLES | ||
| 29 | |||
| 30 | # Create a concrete factory | ||
| 31 | my $factory_implementation = GenOO::RegionCollection::Factory->new('RegionArray', | ||
| 32 | { | ||
| 33 | array => \@array_with_regions | ||
| 34 | } | ||
| 35 | ); | ||
| 36 | |||
| 37 | # Return the actual GenOO::RegionCollection object | ||
| 38 | my $collection = $factory_implementation->read_collection; | ||
| 39 | print ref($collection) # GenOO::RegionCollection::Type::DoubleHashArray | ||
| 40 | |||
| 41 | =cut | ||
| 42 | |||
| 43 | # Let the code begin... | ||
| 44 | |||
| 45 | package GenOO::RegionCollection::Factory::RegionArray; | ||
| 46 | 1 | $GenOO::RegionCollection::Factory::RegionArray::VERSION = '1.4.9'; | |
| 47 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 48 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 49 | |||
| 50 | 1 | ▶ | use GenOO::RegionCollection::Type::DoubleHashArray; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 51 | |||
| 52 | 1 | has 'array' => (is => 'ArrayRef', is => 'ro'); | |
| 53 | |||
| 54 | 1 | with 'GenOO::RegionCollection::Factory::Requires'; | |
| 55 | |||
| 56 | ####################################################################### | ||
| 57 | ######################## Interface Methods ######################## | ||
| 58 | ####################################################################### | ||
| 59 | sub read_collection { | ||
| 60 | 16 | ▶ | my ($self) = @_; |
|
Subroutine
read_collection: called CC=2 SCAR=6.9
Pod
undocumented
| |||
| 61 | |||
| 62 | 16 | my $collection = GenOO::RegionCollection::Type::DoubleHashArray->new; | |
| 63 | |||
| 64 | 16 | foreach my $record ( @{$self->array} ) { | |
| 65 | 786 | $collection->add_record($record); | |
| 66 | } | ||
| 67 | |||
| 68 | 16 | return $collection; | |
| 69 | } | ||
| 70 | |||
| 71 | 1 | 1; | |