Object::Relation::Schema is a Object::Relation data store schema generation.
my $sg = Object::Relation::Schema->new;
This module generates and outputs to a file the schema information necessary to create a data store for a Object::Relation application.
my $sg = Object::Relation::Schema->new($handle_class);
Creates and returns a new Schema object. This is a factory constructor; it will return the subclass corresponding to the handle class name passed as the sole argument.
my @classes = $sg->classes;
The Object::Relation::Meta::Class objects representing classes loaded by the load_classes() method. The classes will be returned in an order appropriate for satisfying dependencies; that is, classes that depend on other classes will be returned after the classes on which they depend.
Pass in a list of classes to set them explicitly. Dependency ordering will not be guaranteed after setting the classes, so be sure to pass them in in the order you need them.
Uses File::Find::Rule to find and load all Perl modules found in the directories specified and their subdirectories, and stores the the Object::Relation::Meta::Class objects for each that inherits from Object::Relation::Base. If the last argument so the method is not a File::Find::Rule object, one will be created that ignores directories named .svn and CVS and loads all files that end in .pm and do not contain "#" in their names. If you need something more strict or lenient, create your own File::Find::Rule object and pass it as the last argument. Use Unix-style directory naming for the directory arguments; load_classes() will automatically convert the them to the appropriate format for the current operating system.
Writes the data store schema generation code to $file_name. If the file or its directory path don't exist, they will be created. All classes loaded by load_classes() will have their schemas written to the file. The optional hash reference takes a number of possible keys:
If set to a true value, this parameter causes the Object::Relation framework's class schema and setup code to be written to the file, as well. This is useful for setting up a Object::Relation application with a new database.
my $code = $sg->begin_schema;
Returns any schema code to be output at the beginning of a schema file. Returns undef by default, but subclasses may override it.
my $code = $sg->end_schema;
Returns any schema code to be output at the end of a schema file. Returns undef by default, but subclasses may override it.
my $code = $sg->setup_code;
Returns any schema code necessary for setting up a data store, such as sequences or database functions. This code will be output by write_schema() before any of the class schema code. Returns undef by default, but subclasses may override it.
my @schema = $sg->schema_for_class($class);
Returns a list of the schema statements that can be used to build the data store for the class passed as an argument. The class can be either a class name or a Object::Relation::Meta::Class object, but must have been loaded by load_classes(). This method is abstract; it must be implemented by subclasses.