Rose::Planter - Keep track of classes created with Rose::DB::Object::Loader.
In My/Objects.pm :
package My::Objects; use Rose::Planter loader_params => { class_prefix => "My::Object", db_class => "My::DB", }, nested_tables => { foo => [ qw(params) ] }, convention_manager_params => {};
In plant.pl :
#!/usr/bin/env perl Rose::Planter->plant("My::Objects" => "My/Objects/autolib");
In another file :
use My::Objects; my $class = Rose::Planter->find_class("my_table"); my $object = Rose::Planter->find_object("my_table","my_key1","my_key2");
This is a thin layer above Rose::DB::Object::Loader for keeping track of and managing classes which are created based on a database schema. It will transparently either query the database using Rose::DB::Object::Loader or use an auto-generated class hierarchy.
This module works well with Module::Build::Database and Clustericious to create a simple RESTful service based on a database schema. It can be used to provide a common base class, conventions, and settings for a collection of services, as well as describe which tables within a schema should be coupled with other tables during CRUD operations.
By default the loader is told that the base_class should be Rose::Planter::Soil. You can send "base_classes" or just "base_class" as loader_params to changes this.
nested_tables will cause find_object to automatically join tables connected to the primary table with a many-to-one relationship.
Rose::Planter->plant($class => $dir)
Write a class hierarchy to disk. This will send the make_modules parameter to Rose::DB::Object::Loader. The directory used will default to My/Objects/autolib. This directory is also searched when My::Objects uses Rose::Planter.
For each class, if the class already exists in @INC, the source from that class will be included in the autogenerated class.
Return a list of all tables.
Create a regex that matches all the tables.
Return a list of all plurals.
Create a regex that matches all the plurals.
Given the name of a database table, return the object class associated with it. e.g.
Rose::Planter->find_class("app");
If the table name ends in _def, the prefix may be used, e.g these are equivalent :
Rose::Planter->find_class("esdt_def"); Rose::Planter->find_class("esdt");
Also, given the plural of the name of a database table, return the manager class associated with it.
Rose::Planter->find_class("esdts"); Rose::Planter->find_class("apps");
Given a table and a primary or other unique key(s), find a load an object.
Return false if there is no object matching that key.
This is a beta release. The API is subject to change without notice.
Marty Brandon
Brian Duggan
Graham Ollis
Curt Tilmes
Currently only really used/tested against postgres.
To install Rose::Planter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Rose::Planter
CPAN shell
perl -MCPAN -e shell install Rose::Planter
For more information on module installation, please visit the detailed CPAN module installation guide.