Gideon::Manual::Creating - Creating objects
version 0.0.3
You can easily persist new object in any gideon data store by using the save method
save
save([ %opts ])
To store a new object you just simply need to call the save method on any newly created instance. And returns the object if the saving was successful or undef if the saving operation failed.
undef
my $new_person = People->new( age => 34, name => 'Mike' ); say 'Success' if $new_person->save;
Gideon has a plugin that would rise an exception in case the operation fails rather than returning undef. Please refer to Gideon::Plugin::StrictMode for more details.
my $new_person = People->new( age => 34, name => 'Mike' ); try { $new_person->save( -strict => 1 ); say 'Success'; } catch { say 'Failed'; };
In the case of objects persisted into RDB's and auto increment values, Gideon would auto populate the resulting id back into the object
my $new_person = People->new( age => 34, name => 'Mike' ); say $new_person->id; # undef $new_person->save; say $new_person->id; # '1'
Creating objects with Gideon
Mariano Wahlmann, Gines Razanov
This software is copyright (c) 2013 by Mariano Wahlmann, Gines Razanov.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Gideon, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gideon
CPAN shell
perl -MCPAN -e shell install Gideon
For more information on module installation, please visit the detailed CPAN module installation guide.