Module::Generic::Dynamic - Dynamic Object Class
package My::Module; use parent qw( Module::Generic::Dynamic ); # Then, instantiating an object my $object = My::Module->new({ name => $some_name, quantity => 20, metadata => $some_hash_reference, tags => [qw( product entrepreneurship capital )], }); # Then the methods corresponding to the data keys can be accessed my $product_name = $object->name # etc
v1.2.4
The purpose of this class/package is to provide a framework to create dynamically created class/package.
For more ganular control over the method to be used for each data key-value, use "_set_get_class" in Module::Generic
Provided with an hash reference of data, this will create dynamically a class based on the class/pacakge name used to call new
It will then associate helper method sbased on the data type for each key of the hash reference. Precisely:
This would create method after the key name and a new class also based on the key name, and use the helper method "_set_get_object" in Module::Generic
If the array contains hash references, this will create a new class/package dynamically and create an object for each hash reference in the array using "_set_get_object_array" in Module::Generic
Otherwise, it will create the method using "_set_get_array" in Module::Generic
This would create a method using the helper method "_set_get_scalar" in Module::Generic
This would create a method using the helper method "_set_get_boolean" in Module::Generic
Serialisation by CBOR, Sereal and Storable::Improved (or the legacy Storable) is supported by this package. To that effect, the following subroutines are implemented: FREEZE, THAW, STORABLE_freeze and STORABLE_thaw
FREEZE
THAW
STORABLE_freeze
STORABLE_thaw
Jacques Deguest <jack@deguest.jp>
Copyright (c) 2000-2020 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.
To install Module::Generic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::Generic
CPAN shell
perl -MCPAN -e shell install Module::Generic
For more information on module installation, please visit the detailed CPAN module installation guide.