.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Alzabo::MethodMaker 3pm" .TH Alzabo::MethodMaker 3pm "2015-05-24" "perl v5.20.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh \fI\f(CI$self\fI\->{name}\fR .IX Subsection "$self->{name}" .PP \&\f(CW$desc\fR .PP \&\s-1EOF \s0 \f(CW$pod\fR .= \f(CW$params\fR if \f(CW$params\fR; .PP .Vb 2 \& return $pod; \&} .Ve .PP package Alzabo::ClassDocs; .PP use Params::Validate qw( validate \s-1SCALAR \s0); .PP use base qw(Alzabo::Docs); .PP sub new { my \f(CW$class\fR = shift; my \f(CW%p\fR = validate( \f(CW@_\fR, { group => { type => \s-1SCALAR \s0}, description => { type => \s-1SCALAR \s0}, } ); .PP .Vb 2 \& return bless \e%p, $class; \&} .Ve .PP sub as_pod { my \f(CW$self\fR = shift; .PP .Vb 2 \& return ucfirst "$self\->{description}\en\en"; \&} .Ve .PP 1; .PP _\|_END_\|_ .SH "NAME" Alzabo::MethodMaker \- Auto\-generate useful methods based on an existing schema .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Alzabo::MethodMaker ( schema => \*(Aqschema_name\*(Aq, all => 1 ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module can take an existing schema and generate a number of useful methods for this schema and its tables and rows. The method making is controlled by the parameters given along with the use statement, as seen in the \s-1SYNOPSIS\s0 section. .SH "PARAMETERS" .IX Header "PARAMETERS" These parameters are all passed to the module when it is imported via \&\f(CW\*(C`use\*(C'\fR. .IP "\(bu" 4 schema => \f(CW$schema_name\fR .Sp This parameter is \fBrequired\fR. .IP "\(bu" 4 class_root => \f(CW$class_name\fR .Sp If given, this will be used as the root of the class names generated by this module. This root should not end in '::'. If none is given, then the calling module's name is used as the root. See New Class Names for more information. .IP "\(bu" 4 all => \f(CW$bool\fR .Sp This tells this module to make all of the methods it possibly can. See \s-1METHOD CREATION OPTIONS\s0 for more details. .Sp If individual method creation options are set as false, then that setting will be respected, so you could use .Sp .Vb 1 \& use Alzabo::MethodMaker( schema => \*(Aqfoo\*(Aq, all => 1, tables => 0 ); .Ve .Sp to turn on all of the regular options \fBexcept\fR for \*(L"tables\*(R". .IP "\(bu" 4 name_maker => \e&naming_sub .Sp If provided, then this callback will be called any time a method name needs to be generated. This allows you to have full control over the resulting names. Otherwise names are generated as described in the documentation. .Sp The callback is expected to return a name for the method to be used. This name should not be fully qualified or contain any class designation as this will be handled by MethodMaker. .Sp It is important that none of the names returned conflict with existing methods for the object the method is being added to. .Sp For example, when adding methods that return column objects to a table, if you have a column called 'name' and try to use that as the method name, it won't work. \f(CW\*(C`Alzabo::Table\*(C'\fR objects already have such a method, which returns the name of the table. See the relevant documentation of the schema, table, and row objects for a list of methods they contain. .Sp The \s-1NAMING SUB PARAMETERS\s0 section contains the details of what parameters are passed to this callback. .Sp \&\fIPlease note\fR that if you have a large complex schema you will almost certainly need to provide a custom naming subroutine to avoid name conflicts. .SH "EFFECTS" .IX Header "EFFECTS" Using this module has several effects on your schema's objects. .SS "New Class Names" .IX Subsection "New Class Names" Your schema, table, and row objects to be blessed into subclasses of \&\f(CW\*(C`Alzabo::Runtime::Schema\*(C'\fR, \&\f(CW\*(C`Alzabo::Runtime::Table\*(C'\fR, \&\f(CW\*(C`Alzabo::Runtime::Row\*(C'\fR, respectively. These subclasses contain the various methods created by this module. The new class names are formed by using the \&\*(L"class_root\*(R" parameter and adding onto it. .PP In order to make it convenient to add new methods to the table and row classes, the created table classes are all subclasses of a new class based on your class root, and the same thing is done for all created row classes. .IP "\(bu" 4 Schema .Sp .Vb 1 \& ::Schema .Ve .IP "\(bu" 4 Tables .Sp .Vb 1 \& ::Table:: .Ve .Sp All tables will be subclasses of: .Sp .Vb 1 \& ::Table .Ve .IP "\(bu" 4 Rows .Sp .Vb 1 \& ::Row::
.Ve .Sp All rows will be subclasses of: .Sp .Vb 1 \& ::Row .Ve .PP With a root of \*(L"My::MovieDB\*(R", and a schema with only two tables, \&\*(L"Movie\*(R" and \*(L"Image\*(R", this would result in the following class names: .PP .Vb 1 \& My::MovieDB::Schema \& \& My::MovieDB::Table::Movie \- subclass of My::MovieDB::Table \& My::MovieDB::Row::Movie \- subclass of My::MovieDB::Row \& \& My::MovieDB::Table::Image \- subclass of My::MovieDB::Table \& My::MovieDB::Row::Image \- subclass of My::MovieDB::Row .Ve .SS "Loading Classes" .IX Subsection "Loading Classes" For each class into which an object is blessed, this module will attempt to load that class via a \f(CW\*(C`use\*(C'\fR statement. If there is no module found this will not cause an error. If this class defines any methods that have the same name as those this module generates, then this module will not attempt to generate them. .SH "METHOD CREATION OPTIONS" .IX Header "METHOD CREATION OPTIONS" When using Alzabo::MethodMaker, you may specify any of the following parameters. Specifying \*(L"all\*(R" causes all of them to be used. .SS "Schema object methods" .IX Subsection "Schema object methods" .IP "\(bu" 4 tables => \f(CW$bool\fR .Sp Creates methods for the schema that return the table object matching the name of the method. .Sp For example, given a schema containing tables named \*(L"Movie\*(R" and \&\*(L"Image\*(R", this would create methods that could be called as \f(CW\*(C`$schema\->Movie\*(C'\fR and \f(CW\*(C`$schema\->Image\*(C'\fR. .SS "Table object methods." .IX Subsection "Table object methods." .IP "\(bu" 4 table_columns => \f(CW$bool\fR .Sp Creates methods for the tables that return the column object matching the name of the method. This is quite similar to the \f(CW\*(C`tables\*(C'\fR option for schemas. So if our \*(L"Movie\*(R" table had a column called \*(L"title\*(R", we could write \f(CW\*(C`$schema\->Movie\->title\*(C'\fR. .IP "\(bu" 4 insert_hooks => \f(CW$bool\fR .Sp Look for hooks to wrap around the \f(CW\*(C`insert()\*(C'\fR method in \&\f(CW\*(C`Alzabo::Runtime::Table\*(C'\fR. See Loading Classes for more details. You have to define either a \&\f(CW\*(C`pre_insert()\*(C'\fR and/or \f(CW\*(C`post_insert()\*(C'\fR method for the generated table class or this parameter will not do anything. See the \&\s-1HOOKS\s0 section for more details. .SS "Row object methods" .IX Subsection "Row object methods" .IP "\(bu" 4 row_columns => \f(CW$bool\fR .Sp This tells MethodMaker to create get/set methods for each column a row has. These methods take a single optional argument, which if given will cause that column to be updated for the row. .IP "\(bu" 4 update_hooks => \f(CW$bool\fR .Sp Look for hooks to wrap around the \f(CW\*(C`update\*(C'\fR method in \&\f(CW\*(C`Alzabo::Runtime::Row\*(C'\fR. See Loading Classes for more details. You have to define a \f(CW\*(C`pre_update()\*(C'\fR and/or \f(CW\*(C`post_update()\*(C'\fR method for the generated row class or this parameter will not do anything. See the \s-1HOOKS\s0 section for more details. .IP "\(bu" 4 select_hooks => \f(CW$bool\fR .Sp Look for hooks to wrap around the \f(CW\*(C`select\*(C'\fR method in \&\f(CW\*(C`Alzabo::Runtime::Row\*(C'\fR. See Loading Classes for more details. You have to define either a \&\f(CW\*(C`pre_select()\*(C'\fR and/or \f(CW\*(C`post_select()\*(C'\fR method for the generated row class or this parameter will not do anything. See the \&\s-1HOOKS\s0 section for more details. .IP "\(bu" 4 delete_hooks => \f(CW$bool\fR .Sp Look for hooks to wrap around the \f(CW\*(C`delete\*(C'\fR method in \&\f(CW\*(C`Alzabo::Runtime::Row\*(C'\fR. See Loading Classes for more details. You have to define either a \&\f(CW\*(C`pre_delete()\*(C'\fR and/or \f(CW\*(C`post_delete()\*(C'\fR method for the generated row class or this parameter will not do anything. See the \&\s-1HOOKS\s0 section for more details. .IP "\(bu" 4 foreign_keys => \f(CW$bool\fR .Sp Creates methods in row objects named for the table to which the relationship exists. These methods return either a single \&\f(CW\*(C`Alzabo::Runtime::Row\*(C'\fR object or a single \&\f(CW\*(C`Alzabo::Runtime::RowCursor\*(C'\fR object, depending on the cardinality of the relationship. .Sp For exa .Sp .Vb 5 \& Movie Credit \& \-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\- \& movie_id movie_id \& title person_id \& role_name .Ve .Sp This would create a method for Movie row objects called \f(CW\*(C`Credit()\*(C'\fR which would return a cursor for the associated Credit table rows. Similarly, Credit row objects would have a method called \f(CW\*(C`Movie()\*(C'\fR which would return the associated Movie row object. .IP "\(bu" 4 linking_tables => \f(CW$bool\fR .Sp A linking table, as defined here, is a table with a two column primary key, with each column being a foreign key to another table's primary key. These tables exist to facilitate n..n logical relationships. If both \f(CW\*(C`foreign_keys\*(C'\fR and \f(CW\*(C`linking_tables\*(C'\fR are true, then methods will be created that skip the intermediate linking tables. .Sp For example, with the following tables: .Sp .Vb 4 \& User UserGroup Group \& \-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\- \& user_id user_id group_id \& user_name group_id group_name .Ve .Sp The \*(L"UserGroup\*(R" table exists solely to facilitate the n..n relationship between \*(L"User\*(R" and \*(L"Group\*(R". User row objects will have a \&\f(CW\*(C`Group()\*(C'\fR method, which returns a row cursor of Group row objects. And Group row objects will have a \f(CW\*(C`User()\*(C'\fR method which returns a row cursor of User row objects. .IP "\(bu" 4 lookup_columns => \f(CW$bool\fR .Sp Lookup columns are columns in foreign tables to which a table has a many-to-one or one-to-one relationship to the foreign table's primary key. For example, given the tables below: .Sp .Vb 6 \& Restaurant Cuisine \& \-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\- \& restaurant_id cuisine_id \& restaurant_name (n..1) description \& phone spiciness \& cuisine_id .Ve .Sp In this example, Restaurant row objects would have \&\f(CW\*(C`Cuisine_description()\*(C'\fR and \f(CW\*(C`Cuisine_spiciness\*(C'\fR methods which returned the corresponding values from the \f(CW\*(C`Cuisine\*(C'\fR table. .IP "\(bu" 4 self_relations => \f(CW$bool\fR .Sp A self relation is when a table has a parent/child relationship with itself. Here is an example: .Sp .Vb 5 \& Location \& \-\-\-\-\-\-\-\- \& location_id \& location_name \& parent_location_id .Ve .Sp \&\s-1NOTE:\s0 If the relationship has a cardinality of 1..1 then no methods will be created, as this option is really intended for parent/child relationships. This may change in the future. .Sp In this case, Location row objects will have both \f(CW\*(C`parent()\*(C'\fR and \&\f(CW\*(C`children()\*(C'\fR methods. The parent method returns a single row, while the \f(CW\*(C`children()\*(C'\fR method returns a row cursor of Location rows. .SH "HOOKS" .IX Header "HOOKS" As was mentioned previously, it is possible to create pre\- and post-execution hooks to wrap around a number of methods. This allows you to do data validation on inserts and updates as well as giving you a chance to filter incoming or outgoing data as needed. For example, this can be used to convert dates to and from a specific \s-1RDBMS\s0 format. .PP All hooks are inside a transaction which is rolled back if any part of the process fails. .PP It should be noted that Alzabo uses both the \f(CW\*(C`Alzabo::Runtime::Row\->select\*(C'\fR and \f(CW\*(C`Alzabo::Runtime::Row\->delete\*(C'\fR methods internally. If their behavior is radically altered through the use of hooks, then some of Alzabo's functionality may be broken. .PP Given this, it may be safer to create new methods to fetch and massage data rather than to create post-select hooks that alter data. .PP Each of these hooks receives different parameters, documented below: .SS "Insert Hooks" .IX Subsection "Insert Hooks" .IP "\(bu" 4 pre_insert .Sp This method receives a hash reference of all the parameters that are passed to the \f(CW\*(C`Alzabo::Runtime::Table\->insert()\*(C'\fR method. .Sp These are the actual parameters that will be passed to the \f(CW\*(C`insert\*(C'\fR method so alterations to this reference will be seen by that method. This allows you to alter the values that actually end up going into the database or change any other parameters as you see fit. .IP "\(bu" 4 post_insert .Sp This method also receives a hash reference containing all of the parameters passed to the \f(CW\*(C`insert()\*(C'\fR method. In addition, the hash reference contains an additional key, \*(L"row\*(R", which contains the newly created row. .SS "Update Hooks" .IX Subsection "Update Hooks" .IP "\(bu" 4 pre_update .Sp This method receives a hash reference of the parameters that will be passed to the \f(CW\*(C`Alzabo::Runtime::Row\->update()\*(C'\fR method. Again, alterations to these parameters will be seen by the \f(CW\*(C`update\*(C'\fR method. .IP "\(bu" 4 post_update .Sp This method receives the same parameters as \f(CW\*(C`pre_update()\*(C'\fR .SS "Select Hooks" .IX Subsection "Select Hooks" .IP "\(bu" 4 pre_select .Sp This method receives an array reference containing the names of the requested columns. This is called when either the \f(CW\*(C`Alzabo::Runtime::Row\->select()\*(C'\fR or \&\f(CW\*(C`Alzabo::Runtime::Row\->select_hash()\*(C'\fR methods are called. .IP "\(bu" 4 post_select .Sp This method is called after the \f(CW\*(C`Alzabo::Runtime::Row\->select()\*(C'\fR or \f(CW\*(C`Alzabo::Runtime::Row\->select_hash()\*(C'\fR methods. It receives a hash containing the name and values returned from the revelant method, which it may modify. If the values of this hash reference are modified, then this will be seen by the original caller. .SS "Delete hooks" .IX Subsection "Delete hooks" .IP "\(bu" 4 pre_delete .Sp This method receives no parameters. .SH "NAMING SUB PARAMETERS" .IX Header "NAMING SUB PARAMETERS" The naming sub will receive a hash containing the following parameters: .IP "\(bu" 4 type => \f(CW$method_type\fR .Sp This will always be the same as one of the parameters you give to the import method. It will be one of the following: \*(L"foreign_key\*(R", \&\*(L"linking_table\*(R", \*(L"lookup_columns\*(R", \*(L"row_column\*(R", \*(L"self_relation\*(R", \&\*(L"table\*(R", \*(L"table_column\*(R". .PP The following parameters vary from case to case, depending on the value of \*(L"type\*(R". .PP When the type is \*(L"table\*(R": .IP "\(bu" 4 table => Alzabo::Table object .Sp This parameter will be passed when the type is \f(CW\*(C`table\*(C'\fR. It is the table object the schema object's method will return. .PP When the type is \*(L"table_column\*(R" or \*(L"row_column\*(R": .IP "\(bu" 4 column => Alzabo::Column object .Sp When the type is \*(L"table_column\*(R", this is the column object the method will return. When the type is \*(L"row_column\*(R", then it is the column whose \fBvalue\fR the method will return. .PP When the type is \*(L"foreign_key\*(R", \*(L"linking_table\*(R", or \*(L"self_relation\*(R": .IP "\(bu" 4 foreign_key => Alzabo::ForeignKey object .Sp This is the foreign key on which the method is based. .PP It is possible to create an n..n relationship between a table and itself, and MethodMaker will attempt to generate linking table methods for such relationships, so your naming sub may need to take this into account. .PP When the type is \*(L"foreign_key\*(R": .IP "\(bu" 4 plural => \f(CW$bool\fR .Sp This indicates whether or not the method that is being created will return a cursor object (true) or a row object (false). .PP When the type is \*(L"linking_table\*(R": .IP "\(bu" 4 foreign_key_2 => Alzabo::ForeignKey object .Sp When making a linking table method, two foreign keys are used. The \&\f(CW\*(C`foreign_key\*(C'\fR is from the table being linked from to the linking table. This parameter is the foreign key from the linking table to the table being linked to. .PP When the type is \*(L"lookup_columns\*(R": .IP "\(bu" 4 column => Alzabo::Column object .Sp When making lookup column methods, this column is the column in the foreign table for which a method is being made. .PP When the type is \*(L"self_relation\*(R": .IP "\(bu" 4 parent => \f(CW$boolean\fR .Sp This indicates whether or not the method being created will return parent objects (true) or child objects (false). .SH "NAMING SUB EXAMPLE" .IX Header "NAMING SUB EXAMPLE" Here is an example that covers all of the possible options: .PP .Vb 1 \& use Lingua::EN::Inflect; \& \& sub namer \& { \& my %p = @_; \& \& # Table object can be returned from the schema via methods such as $schema\->User_t; \& return $p{table}\->name . \*(Aq_t\*(Aq if $p{type} eq \*(Aqtable\*(Aq; \& \& # Column objects are returned similarly, via $schema\->User_t\->username_c; \& return $p{column}\->name . \*(Aq_c\*(Aq if $p{type} eq \*(Aqtable_column\*(Aq; \& \& # If I have a row object, I can get at the columns via their \& # names, for example $user\->username; \& return $p{column}\->name if $p{type} eq \*(Aqrow_column\*(Aq; \& \& # This manipulates the table names a bit to generate names. For \& # example, if I have a table called UserRating and a 1..n \& # relationship from User to UserRating, I\*(Aqll end up with a method \& # on rows in the User table called \->Ratings which returns a row \& # cursor of rows from the UserRating table. \& if ( $p{type} eq \*(Aqforeign_key\*(Aq ) \& { \& my $name = $p{foreign_key}\->table_to\->name; \& my $from = $p{foreign_key}\->table_from\->name; \& $name =~ s/$from//; \& \& if ($p{plural}) \& { \& return my_PL( $name ); \& } \& else \& { \& return $name; \& } \& } \& \& # This is very similar to how foreign keys are handled. Assume \& # we have the tables Restaurant, Cuisine, and RestaurantCuisine. \& # If we are generating a method for the link from Restaurant \& # through to Cuisine, we\*(Aqll have a method on Restaurant table \& # rows called \->Cuisines, which will return a cursor of rows from \& # the Cuisine table. \& # \& # Note: this will generate a bad name if given a linking table \& # that links a table to itself. \& if ( $p{type} eq \*(Aqlinking_table\*(Aq ) \& { \& my $method = $p{foreign_key}\->table_to\->name; \& my $tname = $p{foreign_key}\->table_from\->name; \& $method =~ s/$tname//; \& \& return my_PL($method); \& } \& \& # Lookup columns are columns if foreign tables for which there \& # exists a one\-to\-one or many\-to\-one relationship. In cases such \& # as these, it is often the case that the foreign table is rarely \& # used on its own, but rather it primarily used as a lookup table \& # for values that should appear to be part of other tables. \& # \& # For example, an Address table might have a many\-to\-one \& # relationship with a State table. The State table would contain \& # the columns \*(Aqname\*(Aq and \*(Aqabbreviation\*(Aq. If we have \& # an Address table row, it is convenient to simply be able to say \& # $address\->state_name and $address\->state_abbreviation. \& \& if ( $p{type} eq \*(Aqlookup_columns\*(Aq ) \& { \& return join \*(Aq_\*(Aq, map { lc $_\->name } $p{foreign_key}\->table_to, $p{column}; \& } \& \& # This should be fairly self\-explanatory. \& return $p{parent} ? \*(Aqparent\*(Aq : \*(Aqchildren\*(Aq \& if $p{type} eq \*(Aqself_relation\*(Aq; \& \& # And just to make sure that nothing slips by us we do this. \& die "unknown type in call to naming sub: $p{type}\en"; \& } \& \& # Lingua::EN::Inflect did not handle the word \*(Aqhours\*(Aq properly when this was written \& sub my_PL \& { \& my $name = shift; \& return $name if $name =~ /hours$/i; \& \& return Lingua::EN::Inflect::PL($name); \& } .Ve .SH "GENERATED DOCUMENTATION" .IX Header "GENERATED DOCUMENTATION" This module keeps track of methods that are generated and can in turn generate basic \s-1POD\s0 for those methods. .PP Any schema that has had methods generated for it by Alzabo::MethodMaker will have an additional method, \f(CW\*(C`docs_as_pod\*(C'\fR. This will return documentation for the schema object's methods, as well as any documentation available for objects that the schema contains, in this case tables. The tables in turn return their own documentation plus that of their contained row classes. .PP It is also possible to call the \f(CW\*(C`docs_as_pod\*(C'\fR method on any generated table or row class individually. .PP A simple script like the following can be used to send all of the generated documentation to \f(CW\*(C`STDOUT\*(C'\fR. .PP .Vb 1 \& use Alzabo::MethodMaker ( schema => \*(Aqfoo\*(Aq, all => 1 ); \& \& my $s = Alzabo::Runtime::Schema\->load_from_file( name => \*(Aqfoo\*(Aq ); \& \& print $s\->docs_as_pod; .Ve .SH "AUTHOR" .IX Header "AUTHOR" Dave Rolsky,