Object::Quick::Strict - Stricter form of Object::Quick
See the docs for Object::Quick. Object::Quick::Strict can be used as a drop-in replacement for Object::Quick, the only differences are listed in the DIFFERENCES section.
You cannot use a method until it is initialized either during construction or by assigning a value.
use Object::Quick::Strict qw/obj method clear/; my $one = obj( a => a, method => method { ... } ); ok( $one->a, "a accessor works" ); ok( !$one->can( 'b' ), "Object does not have a 'b' method" ) ok( !eval { $one->b }, "trying to use the 'b' method will die" ); print $@; #Prints that 'b' is not a valid method
You can easily initialize a method
# This will not die, it will initialize 'b' for you. $one->b( 'b' );
Can return undef unless the accessor has been initialized wither through the constructor, or by assigning a value.
Unless the accessor 'something' has been assigned a value this will die.
Chad Granum exodist7@gmail.com
Copyright (C) 2010 Chad Granum
Object-Quick is free software; Standard perl licence.
Object-Quick 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 license for more details.
To install Object::Quick, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Object::Quick
CPAN shell
perl -MCPAN -e shell install Object::Quick
For more information on module installation, please visit the detailed CPAN module installation guide.