NAME Object-Quick - Quickly turn a hash into an object. DESCRIPTION An object created from a hash. Every hash key can be used as a method to get/set the hash element. Creation of a new key is as simple as $obj->newkey( $val ). Essentially an object oriented interface to a hash. WHERE IS THIS USEFUL I urge strongly against using this magic in production code. This object is however very useful in testing code. Sometimes you just need to setup a simulation of an object. Maybe you also need this simulation to have methods that return more objects. SYNOPSYS # Use Object-Quick with a quick-create function name. # Whatever name you provide will be used to create a function that converts # any hash into an object. Providing no name will not import any function. use Object::Quick 'obj'; my $obj = obj( a => 'a' ); print $obj->a; #prints 'a' $obj = obj( a => obj( a => 'a' ); print $obj->a->a; #prints 'a' # You can create objects with attriubtes sharing the names of class-methods $obj = obj( new => 'new' ); print $obj->new; #prints 'new' # New keys can be added trivially $obj->newkey( 'new key!' ); print $obj->newkey; #prints 'new key!' #You can create objets using the package as well: $obj = Object::Quick->new(); EXPORTED FUNCTIONS There is only one exported function, that is the quick-convert function. It is only imported when requested. To import the function add the name you which it to use as an argument to use Object::Quick. use Object::Quick 'quick_convert_function_name'; This function is a shortcut so you don't have to keep typing Object::Quick->new( ... ). It takes any arguments new() accepts. CLASS METHODS There are only 3 class methods. They can only be used as class methods. When used as object method they will act like any other accessor. This allows for objects with attributes named 'new', 'import', and 'AUTOLOAD'. $obj = $class->new( $hashref ) $obj = $class->new( %hash ) $obj = $class->new() The object constructor. Creates a new instance of an object with the provided hash. If no hash is provided an anonymous one will be created. $class->import() $class->import( $quick_create_name ) Automatically called when you use Object::Quick. The optional argument is the name you want to use for the quick create method. AUTOLOAD() This is a special method. This is where the magic happens. Read the perldoc for AUTOLOAD for more details. OBJECT METHODS Anything that is a legal method name can be used. Can be used to get or set the attribute of the object. AUTHORS Chad Granum exodist7@gmail.com COPYRIGHT 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.