package APE::FlushController::Template_FlushController;

use base 'APE::FlushController';

use strict;
use warnings;
use Carp;

use constant TRUE  => 1;
use constant FALSE => 0;

use constant LOGIN => "reports";

{
    my %_attributes = ( 
			## ** Add your object attributes here **
			## They will automatically be given a get method.
			## e.g. attribute 'personForename' can be accessed
			## using getPersonForname(). There are no automatic 
			## set routines, they must be declared or the attribute 
			## value must be parsed in the constructor 
			## i.e new FlushController(personForename=>'Simon');
			
			## You get a reference to this objects ArrayingEntity 
			## object free of charge when this class is created by 
			## by the same ArrayingEntity object! The arrayingEntity 
			## attribute is in the base class and should be accessed 
			## like this: my $entity = ${$self->getArrayingEntity()};

			## You get a reference to a Login::User object that contains
			## a working Login::User::Team and working 
			## Login::User::Team::Role. Access is the same as above.
			## my $userObj = ${$self->getUserObj()};
		       );

    my %object;
    
    foreach my $attName (keys(%_attributes)) {
	no strict 'refs';
	*{__PACKAGE__ . "::get\u$attName"} = sub { $object{ $_[0] }->{$attName} }
    }


    #################################################################
    ## Initialise the objects private attributes. The argument is
    ## deleted as it is found, initialised and set.
    #################################################################
    sub _init {	
	my ($self,%args) = @_;
	foreach my $attName (keys(%args)) {
	    if(exists($_attributes{$attName})) { 
		$object{ $self }->{$attName} = delete $args{$attName};
	    }
	}   
	return $self->SUPER::_init(%args);
    }

    

    
    #################################################################
    ## Over-ridden method from FlushController base class.
    #################################################################
    sub flush {
	warn "GOT TO THE Template_FlushController method.\n";
	my @summary;
	push(@summary, "Template FlushController.");
	$self->report(\@summary);
    }


    #################################################################
    ## Method that should be used to output a sorted summary of the
    ## insertion.
    #################################################################
    sub report {
	my ($self,$summary) = @_;
    }

 
    #################################################################
    ## You may also want to over-ride the following methods from the 
    ## base class.
    #################################################################
    #sub beginTransaction    {}
    #sub rollbackTransaction {}
    #sub commitTransaction   {}


    #################################################################
    ## Method to destroy this object.
    #################################################################
    sub DESTROY {
	my $self = shift;
	delete $object{$self};
	$self->SUPER::DESTROY;
    }
}

1;
