NAME

    App::Betting::Toolkit::GameState - A GameState object for use with App::Betting::Toolkit

VERSION

    Version 0.062

SYNOPSIS

    use App::Betting::Toolkit::GameState;

    my $match = App::Betting::Toolkit::GameState->new();

    $match->name("Arsenal V Aston Villa");

SUBROUTINES/METHODS

new

    Create a new App::Betting::Toolkit::GameState object.

    Default object:

my $match = App::Betting::Toolkit::GameState->new();

    Object with required fields:

my $match = App::Betting::Toolkit::GameState->new( { 
	required => qw(name) 
} );

    Object with auto validation (note validation would always return true here as there are no required fields):

my $match = App::Betting::Toolkit::GameState->new( { 
	options => { autovalidate => 1 } 
} );

    Object with restricted flags, auto validation and required fields:

my $match = App::Betting::Toolkit::GameState->new( {
	options		=>	{ autovalidate => 1 },
	required	=>	[ qw(name time state) ],
	restrict	=>	{
		state	=>	[ qw(suspended active finished) ],
	}
});

    New match objects ALWAYS start invalid.

load

    Load a App::Betting::Toolkit::GameState object from a scalar.

my $unblessedObject = someSouce();

my $match = App::Betting::Toolkit::GameState->load($unblessedObject);

loadable

    Check if a passed object will load without error.

    On error: return 0

    On success: return 1

    if (App::Betting::Toolkit::GameState->loadable($unblessedObject)) {
    	$match = App::Betting::Toolkit::GameState->load($unblessedObject);
    }

pureCopy

    Loop through the match object and return an unblessed scalar version that can be sent elsewhere and loaded with the load function.

    On error: Returns undef

    On success: Returns a unblessed GameState object.

dump

    Return the match as a plain scalar that has been outputted through Data::Dumper

    On error: Something is very wrong 8)

    On success: Returns a Data Dumped scalar of the GameState object.

validate

    Validate the required fields against the current fields in the object, this is done automatically if autovalidate => 1 is set.

    NOTE: This function cannot fail, it will simply just return 0 (invalid)

    On success: Returns 0 or 1 (Invalid or Valid)

isValid

    Return the current validation state.

    On error: Returns undef;

    On success: Returns 0 or 1 (Invalid or Valid)

set

    Set a variable in the match object. If called without a second parameter the current value of the flag will be returned.

    On error: Returns undef;

    On success: Returns new value

    $match->set('team1name','Sheffield Wednesday');
    
    print $match->set('team1name'),"\n"; 

updateTime

    Update the gamestate objects creation time flag, this is handy for if you are storing a copy of a gamestate object somewhere and you need the time to be accurate.

$match->updateTime;

view

    View a variable stored in the match object (does the same as set without its second parameter but does not trigger a validate call even with autovalidate set)

    On error: Returns undef;

    On success: Returns value

    print $match->view('name');

AUTHOR

    Paul G Webster, <daemon at cpan.org>

BUGS

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc App::Betting::Toolkit::GameState

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2013 Paul G Webster.

This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/bsd-license.php

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of Paul G Webster's Organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.