#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::Product::StatusList;

use strict;
use warnings;
use Carp;

use lib '/app/tools/common/lib';
use Common::Assert;


use lib '/app/tools/rps/lib';
use Common::FormObject;
use RPS::Product::Status;
use RPS::DB::Item::ProductStatus;


use base 'Common::FormObject';

sub _init
{
	my ($self, %args) = @_;

	$self->SUPER::_init(%args);


	$self->{Status} = [];
	my $collection = RPS::DB::Item::ProductStatus->GetAll();

	while ($collection->hasNext())
	{
		my $obj = $collection->next();

		push @{$self->{Status}}, new RPS::Product::Status(_dbItem => $obj);
	}

	return $self;
}

sub _listProperties
{
	return
	{
		Status => 1
	};
}

# This is the special sort of list accessor.
#
sub Status
{
	my ($self, $index, $methodAddress, $newValue) = @_;

	if (! $methodAddress)
	{
	 	if (defined $newValue)
		{
			$self->{Status}[$index] = $newValue;
			return 1;
		}
		return $self->{Status}[$index];
	}

	return $self->{Status}[$index]->_accessProperty($methodAddress, $newValue);
}



1;



